summaryrefslogtreecommitdiffstats
path: root/weather.py
diff options
context:
space:
mode:
authorEdi Feschiyan <edi.feschiyan@konsulko.com>2020-06-12 22:44:25 +0300
committerEdi Feschiyan <edi.feschiyan@konsulko.com>2020-06-12 22:44:25 +0300
commit8a8b87e65c0b3d579f8ea420e23a9cd07528dfe1 (patch)
treed5ced56f53104781bf156b38dbad7aba48578ca1 /weather.py
parente2bb2d3ff3f909b9417040de4dd8ea876777a6ee (diff)
Adding cookiecutter, preparing for setuptools, new services
Diffstat (limited to 'weather.py')
-rw-r--r--weather.py48
1 files changed, 0 insertions, 48 deletions
diff --git a/weather.py b/weather.py
deleted file mode 100644
index f3c02d0..0000000
--- a/weather.py
+++ /dev/null
@@ -1,48 +0,0 @@
-import asyncio
-import json
-from aglbaseservice import AGLBaseService, AFBResponse
-
-
-class WeatherService(AGLBaseService):
- service = 'agl-service-weather'
- parser = AGLBaseService.getparser()
- parser.add_argument('--current', default=True, help='Request current weather state', action='store_true')
- 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 current_weather(self):
- return await self.request('current_weather', "")
-
- async def apikey(self):
- return await self.request('api_key', "")
-
-
-async def main():
- args = WeatherService.parser.parse_args()
- aws = await WeatherService(ip=args.ipaddr, port=args.port)
- if args.current:
- id = await aws.current_weather()
- resp = AFBResponse(await aws.response())
- print(json.dumps(resp.data, indent=2))
-
- if args.apikey:
- id = await aws.apikey()
- resp = AFBResponse(await aws.response())
- print(resp.data['api_key'])
-
- if args.subscribe:
- for event in args.subscribe:
- id = await aws.subscribe(event)
- print(f'Subscribed for event {event} with messageid {id}')
- resp = AFBResponse(await aws.response())
- print(resp)
-
- if args.listener:
- async for response in aws.listener():
- print(response)
-
-if __name__ == '__main__':
- loop = asyncio.get_event_loop()
- loop.run_until_complete(main())