Commit b6ba7fd2 authored by Alain Takoudjou's avatar Alain Takoudjou

monitor: check config modification more often

parent 255f61e9
...@@ -154,7 +154,7 @@ md5sum = cc65aebd4c35b3172a7ca83abde761bc ...@@ -154,7 +154,7 @@ md5sum = cc65aebd4c35b3172a7ca83abde761bc
[monitor-document-edit] [monitor-document-edit]
<= monitor-template-script <= monitor-template-script
filename = monitor-document.py filename = monitor-document.py
md5sum = 79c53518e53ae8c8487b09bb49bc7b80 md5sum = f3e557e5d81291a22d6d2837a9e37bd0
[make-rss-script] [make-rss-script]
......
...@@ -7,6 +7,7 @@ import json ...@@ -7,6 +7,7 @@ import json
import argparse import argparse
import subprocess import subprocess
from datetime import datetime from datetime import datetime
import time
def parseArguments(): def parseArguments():
...@@ -144,21 +145,32 @@ if __name__ == "__main__": ...@@ -144,21 +145,32 @@ if __name__ == "__main__":
parser = parseArguments() parser = parseArguments()
parameter_tmp_file = os.path.join(parser.config_folder, 'config.tmp.json') parameter_tmp_file = os.path.join(parser.config_folder, 'config.tmp.json')
config_file = os.path.join(parser.config_folder, 'config.json') config_file = os.path.join(parser.config_folder, 'config.json')
result_dict = applyEditChage(parser)
# Run 4 times with sleep
if result_dict != {}: run_counter = 1
status = True max_runn = 4
for key in result_dict: sleep_time = 15
if not result_dict[key]:
status = False while True:
result_dict = applyEditChage(parser)
if status and os.path.exists(parameter_tmp_file): if result_dict != {}:
try: status = True
os.unlink(config_file) for key in result_dict:
except OSError, e: if not result_dict[key]:
print "ERROR cannot remove file: %s" % parameter_tmp_file status = False
else:
os.rename(parameter_tmp_file, config_file) if status and os.path.exists(parameter_tmp_file):
try:
os.unlink(config_file)
except OSError, e:
print "ERROR cannot remove file: %s" % parameter_tmp_file
else:
os.rename(parameter_tmp_file, config_file)
if run_counter == max_runn:
break
else:
run_counter += 1
time.sleep(sleep_time)
......
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