blob: 6c6cf5680b7a2600b7d77ea1418249b120de2fae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import sys
from cliff.app import App
from cliff.commandmanager import CommandManager
import requests
from testapiclient import user
class TestAPIClient(App):
def __init__(self):
super(TestAPIClient, self).__init__(
description='TestAPI Client',
version='0.1',
command_manager=CommandManager('testapi'),
deferred_help=True,
)
user.User.session = requests.Session()
def initialize_app(self, argv):
self.LOG.debug('initialize_app')
def prepare_to_run_command(self, cmd):
self.LOG.debug('prepare_to_run_command %s', cmd.__class__.__name__)
def clean_up(self, cmd, result, err):
self.LOG.debug('clean_up %s', cmd.__class__.__name__)
if err:
self.LOG.debug('got an error: %s', err)
def main(argv=sys.argv[1:]):
myapp = TestAPIClient()
return myapp.run(argv)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
|