diff --git a/src/main.py b/src/main.py index 4834324..6625144 100755 --- a/src/main.py +++ b/src/main.py @@ -16,24 +16,32 @@ from threading import Timer send_pre = [5, 0, 1, 14, 0, 2, 0, 7, 1, 8] - -def post_thread(): + + +def post_thread(): global counter global post_time_s - counter+=1 - log.info("Posting in %s s",str(post_time_s - counter + 1)) - if counter == post_time_s : - post_scada(node.post_path,args.production) + counter += 1 + log.info("Posting in %s s", str(post_time_s - counter + 1)) + if counter == post_time_s: + post_scada(node.post_path, args.production) counter = 0 - post_timer = Timer(1.0,post_thread) + post_timer = Timer(1.0, post_thread) post_timer.start() - + def build_argparser(): label = subprocess.check_output(["git", "describe"]).strip() parser = argparse.ArgumentParser(description="To select production code") - parser.add_argument('-p','--production', action='store_true', default=False, help = "Create production code") - parser.add_argument('-v','--version', action='version', version=label.decode("utf-8")) + parser.add_argument('-p', + '--production', + action='store_true', + default=False, + help="Create production code") + parser.add_argument('-v', + '--version', + action='version', + version=label.decode("utf-8")) return parser @@ -87,7 +95,7 @@ def poll_loras(loras): if __name__ == "__main__": - + args = build_argparser().parse_args() log = build_logger() @@ -103,12 +111,12 @@ def poll_loras(loras): f_post_boot(node.loras, node.post_path) counter = 0 post_time_s = node.post_time - post_timer = Timer(1.0,post_thread) + post_timer = Timer(1.0, post_thread) post_timer.start() wtd_start.stop() except Watchdog: log.error("Reseting script due to wdt boot") - wtd = Watchdog(300) # 5min + wtd = Watchdog(300) # 5min try: while True: poll_loras(node.loras) @@ -125,4 +133,4 @@ def poll_loras(loras): log.error("App Crashed!") log.error("Problems? %s", sys.exc_info()) log.info("Restarting...") - os.execv(sys.executable, ['python'] + sys.argv) + os.execv(sys.executable, ['python'] + sys.argv)