aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdi Feschiyan <edi.feschiyan@konsulko.com>2020-04-28 12:21:58 +0300
committerEdi Feschiyan <edi.feschiyan@konsulko.com>2020-04-28 12:21:58 +0300
commite6909c77b41db0075cd6c7b4157454602aae7ccb (patch)
treeaa47796d3ead639ec6e3aa1e2268e6eb8c94f56c
parent9da1c8647b233e3a591cc313ebfdac6745806f6d (diff)
Cleaned up geoclue
-rw-r--r--geoclue.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/geoclue.py b/geoclue.py
index ab4eba2..cbccf3b 100644
--- a/geoclue.py
+++ b/geoclue.py
@@ -1,32 +1,29 @@
-import asyncio
-from random import randint
from aglbaseservice import AGLBaseService
+import asyncio
+import os
class GeoClueService(AGLBaseService):
- def __init__(self, ip, port=None, api='geoclue', service='agl-service-geoclue'):
- super().__init__(ip=ip, port=port, api=api, service=service)
+ def __init__(self, ip, port=None, api='geoclue'):
+ super().__init__(ip=ip, port=port, api=api, service='agl-service-geoclue')
async def location(self, waitresponse=False):
return await self.request('location', waitresponse=waitresponse)
- # verb = 'location'
- # msgid = randint(0, 999999)
- #
- # await self.send(f'[2,"{msgid}","{self.api}/{verb}",""]')
- # return await self.receive()
- async def subscribe(self, event='location'):
- super().subscribe(event=event)
+ async def subscribe(self, event='location', waitresponse=False):
+ await super().subscribe(event=event, waitresponse=waitresponse)
- async def unsubscribe(self, event='location'):
- super().unsubscribe(event=event)
+ async def unsubscribe(self, event='location', waitresponse=False):
+ await super().unsubscribe(event=event, waitresponse=waitresponse)
async def main(loop):
- GCS = await GeoClueService(ip='192.168.128.13')
- print(await GCS.location())
- listener = loop.create_task(GCS.listener())
- await listener
+ addr = os.environ.get('AGL_TGT_IP', 'localhost')
+ GCS = await GeoClueService(ip=addr)
+ tasks = []
+ tasks.append(loop.create_task(GCS.location()))
+ tasks.append(loop.create_task(GCS.listener()))
+ loop.run_until_complete(tasks)
if __name__ == '__main__':