-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtroll.py
More file actions
26 lines (24 loc) · 1.02 KB
/
troll.py
File metadata and controls
26 lines (24 loc) · 1.02 KB
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
import json
import requests
from firebase import firebase
import datetime
firebase = firebase.FirebaseApplication("https://light-adapt.firebaseio.com/", None)
# db=shelve.open("base")
def makeunix(st_time):
time_correctly=st_time.split()[1]
return time_correctly
while True:
try:
response = requests.get("http://map.ettu.ru/api/v2/troll/boards/?apiKey=111&order=1").text
data = json.loads(response)["vehicles"]
for information in data:
if information["ROUTE"] =="3":
lat=float(information["LAT"])
lon=float(information["LON"])
board=information["BOARD_ID"]
course=information["COURSE"]
need='{"gps":{"lat":'+str(lat)+', "lon":'+str(lon)+'}, "board_id":'+board+', "course":'+course+"}"
print(need)
push = firebase.put("https://light-adapt.firebaseio.com/", str(makeunix(information["ATIME"])),need)
except:
pass