Skip to content

Commit

Permalink
Refactor standby handling in nocrash.py
Browse files Browse the repository at this point in the history
* Remove switch_to_standby flag.
* Directly manipulate persistent_arguments instead of using a flag variable.  Once we define the launch command, drop 'standby' from the persistent_arguments, and if it receives an exit code to go back into standby, re-add it to the persistent_arguments for the command we pass to the subprocess that spawns ws.py.

This was done in conjunction with Undo in determining how to better fix the handling of 'standby'.
  • Loading branch information
teward committed Feb 26, 2017
1 parent e6adaf5 commit d678491
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions nocrash.py
Expand Up @@ -26,7 +26,6 @@
count = 0
crashcount = 0
stoprunning = False
switch_to_standby = False
ecode = None # Define this to prevent errors

# Make a clean copy of existing environment variables, to pass down to subprocess.
Expand All @@ -41,18 +40,19 @@
# print "[NoCrash] Switch to Standby? %s" % switch_to_standby

if count == 0:
if switch_to_standby or ("standby" in persistent_arguments):
if 'standby' in persistent_arguments:
switch_to_standby = False # Necessary for the while loop
command = 'python ws.py standby'.split()
else:
command = 'python ws.py first_start'.split()
else:
if not switch_to_standby:
if not ('standby' in persistent_arguments):
command = 'python ws.py'.split()
else:
switch_to_standby = False
command = 'python ws.py standby'.split()

persistent_arguments.remove('standby')

try:
ecode = sp.call(command + persistent_arguments, env=environ)
except KeyboardInterrupt:
Expand All @@ -66,8 +66,6 @@
git.submodule('update')
count = 0
crashcount = 0
if "standby" in persistent_arguments:
persistent_arguments.remove("standby")

elif ecode == 4:
# print "[NoCrash] Crashed."
Expand All @@ -93,7 +91,7 @@

elif ecode == 7:
# print "[NoCrash] Go to Standby Restart Called"
switch_to_standby = True
persistent_arguments.append("standby")

elif ecode == 8:
# print "[NoCrash] Checkout Deploy"
Expand Down

0 comments on commit d678491

Please sign in to comment.