blob: 22c2646c8060cf7df0d686ae3f33d763f22b5bc7 (
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
|
import asyncio
from random import randint
import json
from aglbaseservice import AGLBaseService
msgq = {}
class WeatherService(AGLBaseService):
service = 'agl-service-weather'
parser = AGLBaseService.getparser()
parser.add_argument('--apikey', default=False, help='Request weather API Key', action='store_true')
def __init__(self, ip, port=None):
super().__init__(api='weather', ip=ip, port=port, service='agl-service-weather')
async def apikey(self):
return await self.request('api_key', "")
async def main():
args = WeatherService.parser.parse_args()
ws = await WeatherService(ip=args.ipaddr)
if args.apikey:
id = await ws.apikey()
resp = await ws.response()
print(resp[2]['response']['api_key'])
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
|