blob: ef1461a7edcc2baff8ef781c742760dac2a40748 (
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
|
import asyncio
from aglbaseservice import AGLBaseService
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())
|