-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
loggerServer.py
53 lines (47 loc) · 1.63 KB
/
loggerServer.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
#!/usr/bin/python3 -u
import sys
import os
import json
import logging
import traceback
# sys.path.insert(0,'/home/pi/kellerlogger/')
from RTOC.RTLogger.RTLogger import RTLogger
try:
from PyQt5 import QtCore
app = QtCore.QCoreApplication(sys.argv)
# from PyQt5 import QtWidgets
userpath = os.path.expanduser('~/.RTOC')
if os.path.exists(userpath+"/config.json"):
try:
with open(userpath+"/config.json", encoding="UTF-8") as jsonfile:
config = json.load(jsonfile, encoding="UTF-8")
except Exception:
logging.debug(traceback.format_exc())
config = {'global': {'language': 'en'}}
else:
config = {'global': {'language': 'en'}}
if config['global']['language'] == 'de':
translator = QtCore.QTranslator()
if getattr(sys, 'frozen', False):
# frozen
packagedir = os.path.dirname(sys.executable)
else:
# unfrozen
packagedir = os.path.dirname(os.path.realpath(__file__))
translator.load(packagedir+"/RTOC/locales/de_de.qm")
app.installTranslator(translator)
# QtCore.QCoreApplication.installTranslator(translator)
print('German language selected')
except (ImportError, SystemError):
logging.warning('Cannot set language')
logger = RTLogger(True)
try:
# logger.startPlugin('Heliotherm')
# logger.getPlugin('Heliotherm').start('192.168.178.72')
# logger.startPlugin('Futtertrocknung')
a = logger.getThread()
if a is not None:
a.join()
except (KeyboardInterrupt, SystemExit):
logger.stop()
print("LoggerServer stopped by user")