Commit 2c07bd55 authored by Łukasz Nowak's avatar Łukasz Nowak

monitor: Cleanup stale history.json files

parent c3eeed9d
......@@ -123,6 +123,21 @@ def generateMonitoringData(config, public_folder, private_folder, public_url,
except ValueError:
pass
# clean up stale history files
expected_history_json_name_list = [
os.path.basename(q).replace('status.json', 'history.json') for q in file_list]
cleanup_history_json_path_list = []
for history_json_name in [q for q in os.listdir(public_folder) if q.endswith('history.json')]:
if history_json_name not in expected_history_json_name_list:
cleanup_history_json_path_list.append(os.path.join(public_folder, history_json_name))
for cleanup_path in cleanup_history_json_path_list:
try:
os.unlink(cleanup_path)
except Exception:
print('ERROR: Failed to remove stale %s' % (cleanup_path,))
else:
print('OK: Removed stale %s' % (cleanup_path,))
for file in file_list:
try:
with open(file, 'r') as temp_file:
......
Markdown is supported
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