-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paths3watcher-client
executable file
·42 lines (34 loc) · 1.26 KB
/
s3watcher-client
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
40
41
42
#!/usr/bin/env python3
from argparse import ArgumentParser
import asyncio
import logging
from pprint import pprint
from s3watcher.client import S3WatcherClient
import sys
async def run(args):
client = S3WatcherClient(args.address, args.port)
method = getattr(client, args.request.lower(), None)
if method is None:
print('Error: No method for request', args.request,
'in S3WatcherClient', file=sys.stderr)
sys.exit(1)
await client.connect()
method_args = dict([p.split('=') for p in args.params])
data = await method(**method_args)
pprint(data)
def main():
aparser = ArgumentParser(description='S3Watcher client')
aparser.add_argument('request', metavar='REQUEST',
help='request to perform')
aparser.add_argument('params', metavar='PARAMS',
nargs='*', default=[],
help='request parameters')
aparser.add_argument('-a', '--address', default='127.0.0.1',
help='server address')
aparser.add_argument('-p', '--port', type=int, default=7979,
help='server port')
args = aparser.parse_args()
logging.basicConfig()
asyncio.run(run(args))
if __name__ == '__main__':
main()