-
Notifications
You must be signed in to change notification settings - Fork 1
/
trip_update.py
30 lines (27 loc) · 951 Bytes
/
trip_update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import requests
for guid in range(300,310):
payload = """{"guid":"%d","traces":[ %s ]}"""
trace = """{ "type": "Trip", "value":
{ "brake": 0,
"score": 10,
"tilt": 89.95438,
"alt": 0,
"lat": 43,
"lng": -89.004,
"speed": 0,
"time": %d
}
}"""
traces = []
for i in range(190000):
traces.append(trace%(i))
output = payload % (guid,",\n".join(traces))
#print(output)
headers = {
"Authorization":"JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOjE2LCJmaXJzdG5hbWUiOiJQZXRlciIsImxhc3RuYW1lIjoiRGVuIEhhcnRvZyIsImVtYWlsIjoicGRkZW5oYXJAZ21haWwuY29tIiwiaWF0IjoxNDc4OTAzNjA2LCJleHAiOjE0ODE0OTU2MDZ9.vb3OedFyUrGLh23-aTICG8SQ0FcmXfr893kr6IBMPpI",
"Content-Type":"application/json"
}
print("Start request")
r = requests.post("http://drivesense.io/updateTrip", data=output, headers=headers)
print("Sent")
print(r.status_code, r.reason)