works again
This commit is contained in:
parent
acab981293
commit
8008d0262d
|
@ -10,4 +10,6 @@
|
||||||
[Ss]cripts
|
[Ss]cripts
|
||||||
pyvenv.cfg
|
pyvenv.cfg
|
||||||
.venv
|
.venv
|
||||||
pip-selfcheck.json
|
pip-selfcheck.json
|
||||||
|
*.json
|
||||||
|
__pycache__
|
Binary file not shown.
19
test.py
19
test.py
|
@ -14,14 +14,17 @@ def preprocess():
|
||||||
|
|
||||||
print('start init alarms and logs')
|
print('start init alarms and logs')
|
||||||
#versuch beide files zu laden, wenn das fehlschlägt, initiiere beide files als json
|
#versuch beide files zu laden, wenn das fehlschlägt, initiiere beide files als json
|
||||||
try:
|
with open('alarms.json', 'w') as f, open('logs.json','w') as g:
|
||||||
logsFile = json.load(open("./logs.json"))
|
try:
|
||||||
alarmsFile = json.load(open("./alarms.json"))
|
alarmsFile = json.load(f)
|
||||||
except:#no worky
|
logsFile = json.load(g)
|
||||||
print("initiate logs.json")
|
except:
|
||||||
logsFile=json.load(open("./logs.json","w").write("{}"))
|
alarmsFile = list()
|
||||||
print("initiate alarms.json")
|
logsFile = list()
|
||||||
alarmsFile=json.load(open("./alarms.json","w").write("{}"))
|
json.dump(alarmsFile, f, indent=2)
|
||||||
|
json.dump(logsFile, g, indent=2)
|
||||||
|
f.close()
|
||||||
|
g.close()
|
||||||
# schreib alle alarme im File in previousAlarms, wenn sie älter als 2 mins sind
|
# schreib alle alarme im File in previousAlarms, wenn sie älter als 2 mins sind
|
||||||
# alle anderen in active alarms
|
# alle anderen in active alarms
|
||||||
for alarm in alarmsFile:
|
for alarm in alarmsFile:
|
||||||
|
|
Loading…
Reference in New Issue