Merge branch 'chaz' of git://github.com/ChazDazzle/fpdb-chaz
This commit is contained in:
commit
634d102325
|
@ -479,12 +479,13 @@ class Import:
|
|||
self.hhArchiveBase = node.getAttribute("hhArchiveBase")
|
||||
self.hhBulkPath = node.getAttribute("hhBulkPath")
|
||||
self.saveActions = string_to_bool(node.getAttribute("saveActions"), default=False)
|
||||
self.cacheSessions = string_to_bool(node.getAttribute("cacheSessions"), default=False)
|
||||
self.fastStoreHudCache = string_to_bool(node.getAttribute("fastStoreHudCache"), default=False)
|
||||
self.saveStarsHH = string_to_bool(node.getAttribute("saveStarsHH"), default=False)
|
||||
|
||||
def __str__(self):
|
||||
return " interval = %s\n callFpdbHud = %s\n hhArchiveBase = %s\n saveActions = %s\n fastStoreHudCache = %s\n" \
|
||||
% (self.interval, self.callFpdbHud, self.hhArchiveBase, self.saveActions, self.fastStoreHudCache)
|
||||
% (self.interval, self.callFpdbHud, self.hhArchiveBase, self.saveActions, self.cacheSessions, self.fastStoreHudCache)
|
||||
|
||||
class HudUI:
|
||||
def __init__(self, node):
|
||||
|
@ -1260,6 +1261,9 @@ class Config:
|
|||
try: imp['saveActions'] = self.imp.saveActions
|
||||
except: imp['saveActions'] = False
|
||||
|
||||
try: imp['cacheSessions'] = self.imp.cacheSessions
|
||||
except: imp['cacheSessions'] = False
|
||||
|
||||
try: imp['saveStarsHH'] = self.imp.saveStarsHH
|
||||
except: imp['saveStarsHH'] = False
|
||||
|
||||
|
|
|
@ -1967,6 +1967,53 @@ class Database:
|
|||
#print "DEBUG: Successfully updated HudCacho using UPDATE"
|
||||
pass
|
||||
|
||||
def storeSessionsCache(self, pids, starttime, pdata):
|
||||
"""Update cached sessions. If update fails because no record exists, do an insert."""
|
||||
#In development
|
||||
pass
|
||||
|
||||
#update_sessionscache = self.sql.query['update_sessionscache']
|
||||
#update_sessionscache = update_sessionscache.replace('%s', self.sql.query['placeholder'])
|
||||
#insert_sessionscache = self.sql.query['insert_sessionscache']
|
||||
#insert_sessionscache = insert_sessionscache.replace('%s', self.sql.query['placeholder'])
|
||||
#merge_sessionscache = self.sql.query['merge_sessionscache']
|
||||
#merge_sessionscache = merge_sessionscache.replace('%s', self.sql.query['placeholder'])
|
||||
|
||||
#print "DEBUG: %s %s %s" %(hid, pids, pdata)
|
||||
#inserts = []
|
||||
#for p in pdata:
|
||||
#line = [0]*5
|
||||
|
||||
#line[0] = 1 # HDs
|
||||
#line[1] = pdata[p]['totalProfit']
|
||||
|
||||
#line[2] = pids[p] # playerId
|
||||
#line[3] = sessionStart
|
||||
#line[4] = sessionEnd
|
||||
#inserts.append(line)
|
||||
|
||||
|
||||
#cursor = self.get_cursor()
|
||||
|
||||
#for row in inserts:
|
||||
# Try to do the update first:
|
||||
#num = cursor.execute(update_sessionscache, row)
|
||||
#print "DEBUG: values: %s" % row[-3:]
|
||||
# Test statusmessage to see if update worked, do insert if not
|
||||
# num is a cursor in sqlite
|
||||
#if ((self.backend == self.PGSQL and cursor.statusmessage != "UPDATE 1")
|
||||
#or (self.backend == self.MYSQL_INNODB and num == 0)
|
||||
#or (self.backend == self.SQLITE and num.rowcount == 0)):
|
||||
#move the last 6 items in WHERE clause of row from the end of the array
|
||||
# to the beginning for the INSERT statement
|
||||
#print "DEBUG: using INSERT: %s" % num
|
||||
#row = row[-3:] + row[:-3]
|
||||
#num = cursor.execute(insert_sessionscache, row)
|
||||
#print "DEBUG: Successfully(?: %s) updated HudCacho using INSERT" % num
|
||||
#else:
|
||||
#print "DEBUG: Successfully updated HudCacho using UPDATE"
|
||||
#pass
|
||||
|
||||
def isDuplicate(self, gametypeID, siteHandNo):
|
||||
dup = False
|
||||
c = self.get_cursor()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<FreePokerToolsConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FreePokerToolsConfig.xsd">
|
||||
|
||||
<import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True"></import>
|
||||
<import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True" cacheSessions="False"></import>
|
||||
|
||||
<!-- These values determine what stats are displayed in the HUD
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
config_difficulty="expert"
|
||||
/>
|
||||
|
||||
<import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True"></import>
|
||||
<import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True" cacheSessions="False"></import>
|
||||
|
||||
<gui_cash_stats>
|
||||
<col col_name="game" disp_all="True" disp_posn="True" col_title="Game" xalignment="0.0" field_format="%s" field_type="str" />
|
||||
|
|
|
@ -279,6 +279,9 @@ db: a connected Database object"""
|
|||
def updateHudCache(self, db):
|
||||
db.storeHudCache(self.dbid_gt, self.dbid_pids, self.startTime, self.stats.getHandsPlayers())
|
||||
|
||||
def updateSessionsCache(self, db):
|
||||
db.storeSessionsCache(self.dbid_pids, self.startTime, self.stats.getHandsPlayers())
|
||||
|
||||
def select(self, handId):
|
||||
""" Function to create Hand object from database """
|
||||
c = cnxn.cursor()
|
||||
|
|
|
@ -3964,12 +3964,12 @@ class Sql:
|
|||
street2Raises=street2Raises+%s,
|
||||
street3Raises=street3Raises+%s,
|
||||
street4Raises=street4Raises+%s
|
||||
WHERE gametypeId=%s
|
||||
WHERE gametypeId+0=%s
|
||||
AND playerId=%s
|
||||
AND activeSeats=%s
|
||||
AND position=%s
|
||||
AND (case when tourneyTypeId is NULL then 1 else
|
||||
(case when tourneyTypeId=%s then 1 else 0 end) end)=1
|
||||
(case when tourneyTypeId+0=%s then 1 else 0 end) end)=1
|
||||
AND styleKey=%s"""
|
||||
|
||||
self.query['get_hero_hudcache_start'] = """select min(hc.styleKey)
|
||||
|
|
24
pyfpdb/fpdb_import.py
Executable file → Normal file
24
pyfpdb/fpdb_import.py
Executable file → Normal file
|
@ -83,6 +83,7 @@ class Importer:
|
|||
self.pos_in_file = {} # dict to remember how far we have read in the file
|
||||
#Set defaults
|
||||
self.callHud = self.config.get_import_parameters().get("callFpdbHud")
|
||||
self.cacheSessions = self.config.get_import_parameters().get("cacheSessions")
|
||||
|
||||
# CONFIGURATION OPTIONS
|
||||
self.settings.setdefault("minPrint", 30)
|
||||
|
@ -111,6 +112,9 @@ class Importer:
|
|||
def setCallHud(self, value):
|
||||
self.callHud = value
|
||||
|
||||
def setCacheSessions(self, value):
|
||||
self.cacheSessions = value
|
||||
|
||||
def setMinPrint(self, value):
|
||||
self.settings['minPrint'] = int(value)
|
||||
|
||||
|
@ -492,13 +496,21 @@ class Importer:
|
|||
hand.updateHudCache(self.database)
|
||||
self.database.commit()
|
||||
|
||||
# Call sessionsCache update
|
||||
if self.cacheSessions:
|
||||
for hand in handlist:
|
||||
if hand is not None and not hand.is_duplicate:
|
||||
hand.updateSessionsCache(self.database)
|
||||
self.database.commit()
|
||||
|
||||
#pipe the Hands.id out to the HUD
|
||||
for hid in to_hud:
|
||||
try:
|
||||
print _("fpdb_import: sending hand to hud"), hand.dbid_hands, "pipe =", self.caller.pipe_to_hud
|
||||
self.caller.pipe_to_hud.stdin.write("%s" % (hid) + os.linesep)
|
||||
except IOError, e:
|
||||
log.error(_("Failed to send hand to HUD: %s") % e)
|
||||
if self.caller:
|
||||
for hid in to_hud:
|
||||
try:
|
||||
print _("fpdb_import: sending hand to hud"), hand.dbid_hands, "pipe =", self.caller.pipe_to_hud
|
||||
self.caller.pipe_to_hud.stdin.write("%s" % (hid) + os.linesep)
|
||||
except IOError, e:
|
||||
log.error(_("Failed to send hand to HUD: %s") % e)
|
||||
|
||||
errors = getattr(hhc, 'numErrors')
|
||||
stored = getattr(hhc, 'numHands')
|
||||
|
|
Loading…
Reference in New Issue
Block a user