fix get format json

This commit is contained in:
David Malinowski 2024-10-09 13:05:50 +02:00
parent 8705b6c65e
commit e8108ed38e

View File

@ -50,7 +50,8 @@ def get_trips_for_device():
'deviceId': dev['id'], 'deviceId': dev['id'],
'from': (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%dT23:00:00.000Z'), 'from': (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%dT23:00:00.000Z'),
'to': datetime.now().strftime('%Y-%m-%dT22:59:59.999Z') 'to': datetime.now().strftime('%Y-%m-%dT22:59:59.999Z')
} },
headers={'Accept': 'application/json'}
) )
trips_response.raise_for_status() trips_response.raise_for_status()
except requests.HTTPError as e: except requests.HTTPError as e:
@ -58,6 +59,8 @@ def get_trips_for_device():
except Exception as e: except Exception as e:
frappe.throw(f"Error fetching trips: {e}") frappe.throw(f"Error fetching trips: {e}")
print(trips_response.text)
#if len(trips_response.json()) > 0: #if len(trips_response.json()) > 0:
# for debug in trips_response.json(): # for debug in trips_response.json():
# print(f"Distance: {debug['distance']} | Average Speed: {debug['averageSpeed']}") # print(f"Distance: {debug['distance']} | Average Speed: {debug['averageSpeed']}")