From 1889ab023bfff63736621587edf862150ff70402 Mon Sep 17 00:00:00 2001 From: gileadmcgee Date: Thu, 15 Oct 2015 09:11:52 -0700 Subject: [PATCH] fixed a few errors added experimental feedscript scheduling --- scripts/switch-keys/switch.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scripts/switch-keys/switch.py b/scripts/switch-keys/switch.py index a567ed17..043c0162 100755 --- a/scripts/switch-keys/switch.py +++ b/scripts/switch-keys/switch.py @@ -7,6 +7,7 @@ import time import config import subprocess +from time import gmtime, strftime rpc = GrapheneWebsocket("localhost", 8092, "", "") @@ -85,6 +86,26 @@ def resync(): print("waiting...") time.sleep(10) +### testing running feed schedule through script +#def checkTime(lastHour): +# hour = strftime("%H", gmtime()) +# minute = strftime("%M", gmtime()) +# hour = int(hour) +# minute = int(minute) +# if minute % 42 == 0: +# if lastHour == 23: +# if hour == 0: +# subprocess.call(["screen","-S","feed","-p","0","-X","quit"]) +# subprocess.call(["screen","-dmS","feed","python3",config.path_to_feed_script]) +# return hour +# elif hour > lastHour: +# subprocess.call(["screen","-S","feed","-p","0","-X","quit"]) +# subprocess.call(["screen","-dmS","feed","python3",config.path_to_feed_script]) +# return hour +# else: +# return lastHour +# else: +# return lastHour closeScreens() openScreens() @@ -97,6 +118,8 @@ def resync(): lastblock = witness["last_confirmed_block_num"] emergency = False replay = 0 +crash = 0 +lastHour = 0 while True: try: @@ -149,8 +172,10 @@ def resync(): print(config.witnessname + " missed a block. total missed = " + str(missed) + " recent missed = " + str(recentmissed)) lastblock = witness["last_confirmed_block_num"] else: +# lastHour = checkTime(lastHour) waitAndNotify() replay = watch(replay) +### if you are having issue try commenting out the try line and everything below the except line to prevent auto restart except: if crash > 2: crash = watch(crash)