From 91e6e504803e5470223df776dfc90e47cc420d82 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 16 Apr 2020 12:23:32 -0700 Subject: [PATCH] stop broken upgrade early-launch case Wasn't checking for existance of script and so got and exception deleting what didn't exist. Instead I define nonexistance as being too early. --- xwords4/linux/scripts/discon_ok2.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/xwords4/linux/scripts/discon_ok2.py b/xwords4/linux/scripts/discon_ok2.py index cbd9bbd82..a9395ef2b 100755 --- a/xwords4/linux/scripts/discon_ok2.py +++ b/xwords4/linux/scripts/discon_ok2.py @@ -210,12 +210,16 @@ class Device(): def setApp(self, pct): if self.app == self.args.APP_OLD and not self.app == self.args.APP_NEW: - if pct >= random.randint(0, 99): - print('launch(): upgrading from ', self.app, ' to ', self.args.APP_NEW) + if os.path.exists(self.script) and pct >= random.randint(0, 99): + print('launch(): upgrading {} from {} to {}' \ + .format(self.devName(), self.app, self.args.APP_NEW)) self.app = self.args.APP_NEW # nuke script to force regeneration os.unlink(self.script) + def devName(self): + return 'dev_' + str(self.indx) + def logReaderMain(self): assert self and self.proc # print('logReaderMain called; opening:', self.logPath) @@ -679,7 +683,7 @@ def mkParser(): help = 'the app we\'ll upgrade from') parser.add_argument('--start-pct', dest = 'START_PCT', default = 50, type = int, help = 'odds of starting with the new app, 0 <= n < 100') - parser.add_argument('--upgrade-pct', dest = 'UPGRADE_PCT', default = 5, type = int, + parser.add_argument('--upgrade-pct', dest = 'UPGRADE_PCT', default = 20, type = int, help = 'odds of upgrading at any launch, 0 <= n < 100') parser.add_argument('--num-games', dest = 'NGAMES', type = int, default = 1, help = 'number of games')