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.
This commit is contained in:
Eric House 2020-04-16 12:23:32 -07:00
parent 22f62d53e0
commit 91e6e50480

View file

@ -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')