Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -87,7 +95,7 @@ def poll_loras(loras):


if __name__ == "__main__":

args = build_argparser().parse_args()
log = build_logger()

Expand All @@ -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)
Expand All @@ -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)