From d240e30bf47db7bd8f87a1f55628c29c91b0b11e Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 25 May 2018 21:36:25 -0700 Subject: [PATCH] test script: log and show tiles left in tray Once the pool count drops to 0, start showing the number of tiles left in the user's tray. This prevents there being a long time when nothing seems to be changing *and* the script from exiting early because it thinks all games are hung. --- xwords4/common/server.c | 3 +++ xwords4/linux/scripts/discon_ok2.py | 42 ++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/xwords4/common/server.c b/xwords4/common/server.c index 00bcd2e30..a146eee8b 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -2503,6 +2503,9 @@ server_commitMove( ServerCtxt* server, TrayTileSet* newTilesP ) } else { nextTurn( server, PICK_NEXT ); } + + XP_LOGF( "%s(): player %d now has %d tiles", __func__, turn, + model_getNumTilesInTray( model, turn ) ); return XP_TRUE; } /* server_commitMove */ diff --git a/xwords4/linux/scripts/discon_ok2.py b/xwords4/linux/scripts/discon_ok2.py index 5acc8a5fe..2861157e4 100755 --- a/xwords4/linux/scripts/discon_ok2.py +++ b/xwords4/linux/scripts/discon_ok2.py @@ -159,7 +159,8 @@ class Device(): sHasLDevIDMap = {} sConnNamePat = re.compile('.*got_connect_cmd: connName: "([^"]+)".*$') sGameOverPat = re.compile('.*\[unused tiles\].*') - sTilesLeftPat = re.compile('.*pool_removeTiles: (\d+) tiles left in pool') + sTilesLeftPoolPat = re.compile('.*pool_removeTiles: (\d+) tiles left in pool') + sTilesLeftTrayPat = re.compile('.*player \d+ now has (\d+) tiles') sRelayIDPat = re.compile('.*UPDATE games.*seed=(\d+),.*relayid=\'([^\']+)\'.*') def __init__(self, args, game, indx, app, params, room, db, log, nInGame): @@ -180,7 +181,8 @@ class Device(): self.devID = '' self.launchCount = 0 self.allDone = False # when true, can be killed - self.nTilesLeft = None + self.nTilesLeftPool = None + self.nTilesLeftTray = None self.relayID = None self.relaySeed = 0 @@ -212,9 +214,13 @@ class Device(): match = Device.sGameOverPat.match(line) if match: self.gameOver = True - # Check every line for tiles left - match = Device.sTilesLeftPat.match(line) - if match: self.nTilesLeft = int(match.group(1)) + # Check every line for tiles left in pool + match = Device.sTilesLeftPoolPat.match(line) + if match: self.nTilesLeftPool = int(match.group(1)) + + # Check every line for tiles left in tray + match = Device.sTilesLeftTrayPat.match(line) + if match: self.nTilesLeftTray = int(match.group(1)) if not self.relayID: match = Device.sRelayIDPat.match(line) @@ -287,8 +293,11 @@ class Device(): print('got exception sending to', url, params, '; is relay.py running as apache module?') def getTilesCount(self): - return {'index': self.indx, 'nTilesLeft': self.nTilesLeft, - 'launchCount': self.launchCount, 'game': self.game, + return {'index': self.indx, + 'nTilesLeftPool': self.nTilesLeftPool, + 'nTilesLeftTray': self.nTilesLeftTray, + 'launchCount': self.launchCount, + 'game': self.game, } def update_ldevid(self): @@ -675,13 +684,22 @@ def summarizeTileCounts(devs, endTime, state): nLaunches += launchCount fmtData[1]['data'].append('{:{width}d}'.format(launchCount, width=colWidth)) - nTiles = datum['nTilesLeft'] - fmtData[2]['data'].append(nTiles is None and ('-' * colWidth) or '{:{width}d}'.format(nTiles, width=colWidth)) - if not nTiles is None: totalTiles += int(nTiles) - + # Format tiles left. It's the number in the bag/pool until + # that drops to 0, then the number in the tray preceeded by + # '+'. Only the pool number is included in the totalTiles sum. + nTilesPool = datum['nTilesLeftPool'] + nTilesTray = datum['nTilesLeftTray'] + if nTilesPool is None and nTilesTray is None: + txt = ('-' * colWidth) + elif int(nTilesPool) == 0 and not nTilesTray is None: + txt = '+{:{width}d}'.format(nTilesTray, width=colWidth-1) + else: + txt = '{:{width}d}'.format(nTilesPool, width=colWidth) + totalTiles += int(nTilesPool) + fmtData[2]['data'].append(txt) print('') - print('devs left: {}; tiles left: {}; total launches: {}; {}/{}' + print('devs left: {}; bag tiles left: {}; total launches: {}; {}/{}' .format(nDevs, totalTiles, nLaunches, datetime.datetime.now(), endTime )) fmt = '{head:>%d} {data}' % headWidth for datum in fmtData: datum['data'] = ' '.join(datum['data'])