Skip to content

Commit 0f0cb03

Browse files
committed
added async get units method
1 parent dfd9ef4 commit 0f0cb03

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

pytrackunit/trackunit.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,19 @@ def verbose(self, value):
6060
"""sets the verbose mode. in verbose mode, diagnostic output is printed to console."""
6161
self.cache.cache.verbose = value
6262

63-
def get_unitlist(self,_type=None,sort_by_hours=True):
63+
async def _a_get_unitlist(self,_type=None,sort_by_hours=True):
6464
"""unitList method"""
65-
data = asyncio.run(self.cache.get_url('Unit'))
65+
data = await self.cache.get_url('Unit')
6666
if _type is not None:
6767
data = list(filter(lambda x: " " in x['name'] and _type in x['name'],data))
6868
if sort_by_hours:
6969
data.sort(key=lambda x: (x['run1'] if 'run1' in x else 0),reverse=True)
7070
return data
7171

72+
def get_unitlist(self,_type=None,sort_by_hours=True):
73+
"""unitList method"""
74+
return asyncio.run(self._a_get_unitlist(_type,sort_by_hours))
75+
7276
async def _a_get_history(self,veh_id,tdelta):
7377
"""async getHistory method"""
7478
data = []

0 commit comments

Comments
 (0)