Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated AirStatus for current use #25

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Fix deprecation warning on Python newer than v3.6
  • Loading branch information
Abdallah-Abdelazim committed Jun 22, 2022

Unverified

This user has not yet uploaded their public signing key.
commit 2e09948af153dfbf7d26d4445d8d8552c376ff07
15 changes: 10 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@
from json import dumps
from sys import argv
from datetime import datetime
import sys
import asyncio

# Configure update duration (update after n seconds)
UPDATE_DURATION = 1
@@ -55,11 +57,14 @@ async def get_device():

# Same as get_device() but it's standalone method instead of async
def get_data_hex():
new_loop = new_event_loop()
set_event_loop(new_loop)
loop = get_event_loop()
a = loop.run_until_complete(get_device())
loop.close()
if sys.version_info < (3, 7):
new_loop = new_event_loop()
set_event_loop(new_loop)
loop = get_event_loop()
a = loop.run_until_complete(get_device())
loop.close()
else:
a = asyncio.run(get_device())
return a