-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.py
executable file
·59 lines (45 loc) · 1.7 KB
/
start.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
52
53
54
55
56
57
58
59
from dotenv import load_dotenv, find_dotenv
import os
import logging
# Load .env
load_dotenv(find_dotenv())
# Logging configuration
from surirobot.core.common import Dir
import time
if int(os.environ.get('DEBUG', '0')):
print('DEBUG MODE : on')
if int(os.environ.get('LOG', '0')):
logFormatter = logging.Formatter("%(asctime)s [%(threadName)-12.12s] [%(name)-12.12s][%(levelname)-5.5s] %(message)s")
rootLogger = logging.getLogger()
rootLogger.setLevel(level=logging.DEBUG)
filename = '{}{}.txt'.format(Dir.LOG, time.strftime("%Y_%m_%d_%H_%M_%S"))
fileHandler = logging.FileHandler(filename)
fileHandler.setFormatter(logFormatter)
rootLogger.addHandler(fileHandler)
consoleHandler = logging.StreamHandler()
consoleHandler.setFormatter(logFormatter)
rootLogger.addHandler(consoleHandler)
else:
logFormatter = logging.Formatter("%(asctime)s [%(threadName)-12.12s] [%(name)-12.12s][%(levelname)-5.5s] %(message)s")
rootLogger = logging.getLogger()
rootLogger.setLevel(level=logging.DEBUG)
consoleHandler = logging.StreamHandler()
consoleHandler.setFormatter(logFormatter)
rootLogger.addHandler(consoleHandler)
else:
print('DEBUG MODE : off')
logging.basicConfig(level=logging.INFO)
# Launch GUI
from surirobot.core import app
# Launch device services
import surirobot.devices
# Launch API callers
import surirobot.core.api
# Launch services
import surirobot.services
# Launch keyboard listener
# Launch manager
from surirobot.core.manager import manager
if not int(os.environ.get('TEMPORARY_FILES', '0')):
app.aboutToQuit.connect(manager.delete_temporary_files)
app.exec_()