Allows any "msg" from ADSBX to be raised

-Checks msg from ADSBX before looking at ctime
-Raises an error when ADSBX msg is not "No Error"
This commit is contained in:
Jack Sweeney 2020-12-20 13:19:15 -05:00 committed by GitHub
parent 79ff6330d9
commit b724d99330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 7 deletions

View File

@ -57,15 +57,13 @@ def pullADSBX(planes):
if "response" in locals():
print ("HTTP Status Code:", response.status_code)
if failed is False:
data_ctime = float(data['ctime']) / 1000.0
print("UTC of Data:",datetime.utcfromtimestamp(data_ctime))
print("Current UTC:", datetime.utcnow())
try:
if data['msg'] == 'You need a key. Get a feeder or use pay API. https://rapidapi.com/adsbx/api/adsbexchange-com1':
print("Bad auth", data['msg'])
if data['msg'] != "No error":
raise Exception("Error from ADSBX: msg = ", data['msg'])
failed = True
except KeyError:
pass
data_ctime = float(data['ctime']) / 1000.0
print("UTC of Data:",datetime.utcfromtimestamp(data_ctime))
print("Current UTC:", datetime.utcnow())
return data, failed