-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (27 loc) · 792 Bytes
/
main.py
File metadata and controls
37 lines (27 loc) · 792 Bytes
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
31
32
33
34
35
36
37
import json
import sys
from twisted.python import log
import settings
from car import Car
from devices.bce import BCE
from devices.device import Device
from devices.ips import IPS
from loop import Loop
from utils.datehelper import Schedule
def main():
loop = Loop()
log.startLogging(sys.stdout)
log.msg('Starting reactor')
with open(settings.CARS_FILE) as f:
data = json.load(f)
for item in data:
city = item.get('city', 'points')
schedule = Schedule.from_dict(item.get('schedule'))
car = Car(item["VIN"], city, schedule)
device = Device(imei=item["IMEI"], protocol=BCE)
device.connect_to_car(car)
loop.add_object(car)
loop.add_object(device)
loop.start()
if __name__ == '__main__':
main()