mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
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.
This commit is contained in:
parent
89f4246e83
commit
d240e30bf4
2 changed files with 33 additions and 12 deletions
|
@ -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 */
|
||||
|
|
|
@ -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'])
|
||||
|
|
Loading…
Reference in a new issue