-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
51 lines (39 loc) · 1.25 KB
/
main.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from core.control import StabilityControl
from core.web_page import PageGenerator
from core.page_request import PageRequest, Root
from datetime import datetime
import cherrypy
import cherrypy_cors
import threading
import time
cherrypy.config.update({
'global': {
'environment': 'test_suite',
'server.socket_host': '192.168.67.142',
'server.socket_port': 8080,
'cors.expose.on': True
}
})
cherrypy_cors.install()
stab = StabilityControl()
stab.create_stability_stations_list()
stab.read_station_test_plans()
stab.update_stations_statuses()
stab.activation_of_leds()
page = PageGenerator(stab)
cherrypy.tree.mount(Root())
cherrypy.tree.mount(PageRequest(stab, page), '/api', {'/': {'request.dispatch': cherrypy.dispatch.MethodDispatcher()}})
def start_requests():
cherrypy.engine.start()
cherrypy.engine.block()
requests = threading.Thread(target=start_requests)
requests.start()
print("Start running at:", datetime.now())
while True:
try:
stab.update_stations_statuses()
stab.activation_of_leds()
page.generate_page()
time.sleep(1800)
except Exception as e:
print(f"{datetime.now()} - Something went wrong! Exception: {e}")