Commit 21512a51 authored by Alexandre Boyer's avatar Alexandre Boyer
Browse files

fix status

parent 791b2088
Pipeline #124370 passed with stage
in 39 seconds
...@@ -25,9 +25,7 @@ class StatusFactory(): ...@@ -25,9 +25,7 @@ class StatusFactory():
command_states_log = os.path.join(path, states_filename) command_states_log = os.path.join(path, states_filename)
json_command_states = {} json_command_states = {}
if not os.path.isfile(command_states_log) or os.stat(command_states_log).st_size == 0: if os.path.isfile(command_states_log) and os.stat(command_states_log).st_size != 0:
StatusFactory.generate_file(command_states_log, public_subcommands, json_command_states)
else:
with open(command_states_log, 'r') as f: with open(command_states_log, 'r') as f:
try: try:
json_command_states = json.load(f) json_command_states = json.load(f)
...@@ -37,7 +35,10 @@ class StatusFactory(): ...@@ -37,7 +35,10 @@ class StatusFactory():
except: except:
logging.warning("Status monitoring improperly terminated: status reset") logging.warning("Status monitoring improperly terminated: status reset")
os.remove(states_filename) os.remove(states_filename)
StatusFactory.generate_file(command_states_log, public_subcommands, json_command_states)
if not os.path.isfile(command_states_log) or os.stat(command_states_log).st_size == 0:
StatusFactory.generate_file(command_states_log, public_subcommands, json_command_states)
with open(command_states_log, 'w+') as f: with open(command_states_log, 'w+') as f:
json.dump(json_command_states, f) json.dump(json_command_states, f)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment