diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py
index 6edf7059..0dace0bf 100644
--- a/pyfpdb/Database.py
+++ b/pyfpdb/Database.py
@@ -1618,103 +1618,44 @@ class Database:
pdata[p]['street2Bets'],
pdata[p]['street3Bets'],
pdata[p]['street4Bets'],
+ pdata[p]['position'],
+ pdata[p]['tourneyTypeId'],
+ pdata[p]['startCards'],
+ pdata[p]['street0_3BChance'],
+ pdata[p]['street0_3BDone'],
+ pdata[p]['otherRaisedStreet1'],
+ pdata[p]['otherRaisedStreet2'],
+ pdata[p]['otherRaisedStreet3'],
+ pdata[p]['otherRaisedStreet4'],
+ pdata[p]['foldToOtherRaisedStreet1'],
+ pdata[p]['foldToOtherRaisedStreet2'],
+ pdata[p]['foldToOtherRaisedStreet3'],
+ pdata[p]['foldToOtherRaisedStreet4'],
+ pdata[p]['stealAttemptChance'],
+ pdata[p]['stealAttempted'],
+ pdata[p]['foldBbToStealChance'],
+ pdata[p]['foldedBbToSteal'],
+ pdata[p]['foldSbToStealChance'],
+ pdata[p]['foldedSbToSteal'],
+ pdata[p]['foldToStreet1CBChance'],
+ pdata[p]['foldToStreet1CBDone'],
+ pdata[p]['foldToStreet2CBChance'],
+ pdata[p]['foldToStreet2CBDone'],
+ pdata[p]['foldToStreet3CBChance'],
+ pdata[p]['foldToStreet3CBDone'],
+ pdata[p]['foldToStreet4CBChance'],
+ pdata[p]['foldToStreet4CBDone'],
+ pdata[p]['street1CheckCallRaiseChance'],
+ pdata[p]['street1CheckCallRaiseDone'],
+ pdata[p]['street2CheckCallRaiseChance'],
+ pdata[p]['street2CheckCallRaiseDone'],
+ pdata[p]['street3CheckCallRaiseChance'],
+ pdata[p]['street3CheckCallRaiseDone'],
+ pdata[p]['street4CheckCallRaiseChance'],
+ pdata[p]['street4CheckCallRaiseDone']
) )
- q = """INSERT INTO HandsPlayers (
- handId,
- playerId,
- startCash,
- seatNo,
- card1,
- card2,
- card3,
- card4,
- card5,
- card6,
- card7,
- winnings,
- rake,
- totalProfit,
- street0VPI,
- street1Seen,
- street2Seen,
- street3Seen,
- street4Seen,
- sawShowdown,
- wonAtSD,
- street0Aggr,
- street1Aggr,
- street2Aggr,
- street3Aggr,
- street4Aggr,
- street1CBChance,
- street2CBChance,
- street3CBChance,
- street4CBChance,
- street1CBDone,
- street2CBDone,
- street3CBDone,
- street4CBDone,
- wonWhenSeenStreet1,
- street0Calls,
- street1Calls,
- street2Calls,
- street3Calls,
- street4Calls,
- street0Bets,
- street1Bets,
- street2Bets,
- street3Bets,
- street4Bets
- )
- VALUES (
- %s, %s, %s, %s, %s,
- %s, %s, %s, %s, %s,
- %s, %s, %s, %s, %s,
- %s, %s, %s, %s, %s,
- %s, %s, %s, %s, %s,
- %s, %s, %s, %s, %s,
- %s, %s, %s, %s, %s,
- %s, %s, %s, %s, %s,
- %s, %s, %s, %s, %s
- )"""
-
-# position,
-# tourneyTypeId,
-# startCards,
-# street0_3BChance,
-# street0_3BDone,
-# otherRaisedStreet1,
-# otherRaisedStreet2,
-# otherRaisedStreet3,
-# otherRaisedStreet4,
-# foldToOtherRaisedStreet1,
-# foldToOtherRaisedStreet2,
-# foldToOtherRaisedStreet3,
-# foldToOtherRaisedStreet4,
-# stealAttemptChance,
-# stealAttempted,
-# foldBbToStealChance,
-# foldedBbToSteal,
-# foldSbToStealChance,
-# foldedSbToSteal,
-# foldToStreet1CBChance,
-# foldToStreet1CBDone,
-# foldToStreet2CBChance,
-# foldToStreet2CBDone,
-# foldToStreet3CBChance,
-# foldToStreet3CBDone,
-# foldToStreet4CBChance,
-# foldToStreet4CBDone,
-# street1CheckCallRaiseChance,
-# street1CheckCallRaiseDone,
-# street2CheckCallRaiseChance,
-# street2CheckCallRaiseDone,
-# street3CheckCallRaiseChance,
-# street3CheckCallRaiseDone,
-# street4CheckCallRaiseChance,
-# street4CheckCallRaiseDone,
-
+ q = self.sql.query['store_hands_players']
q = q.replace('%s', self.sql.query['placeholder'])
#print "DEBUG: inserts: %s" %inserts
@@ -1927,8 +1868,10 @@ class Database:
,(name, site_id))
#Get last id might be faster here.
#c.execute ("SELECT id FROM Players WHERE name=%s", (name,))
- tmp = [self.get_last_insert_id(c)]
- return tmp[0]
+ result = self.get_last_insert_id(c)
+ else:
+ result = tmp[1]
+ return result
def insertGameTypes(self, row):
c = self.get_cursor()
diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py
index e4072d8a..dbd655a3 100644
--- a/pyfpdb/DerivedStats.py
+++ b/pyfpdb/DerivedStats.py
@@ -17,6 +17,7 @@
#fpdb modules
import Card
+from decimal import Decimal
DEBUG = False
@@ -43,9 +44,9 @@ class DerivedStats():
self.handsplayers[player[1]]['totalProfit'] = 0
self.handsplayers[player[1]]['street4Seen'] = False
self.handsplayers[player[1]]['street4Aggr'] = False
- self.handsplayers[player[1]]['wonWhenSeenStreet1'] = False
+ self.handsplayers[player[1]]['wonWhenSeenStreet1'] = 0.0
self.handsplayers[player[1]]['sawShowdown'] = False
- self.handsplayers[player[1]]['wonAtSD'] = False
+ self.handsplayers[player[1]]['wonAtSD'] = 0.0
for i in range(5):
self.handsplayers[player[1]]['street%dCalls' % i] = 0
self.handsplayers[player[1]]['street%dBets' % i] = 0
@@ -53,6 +54,27 @@ class DerivedStats():
self.handsplayers[player[1]]['street%dCBChance' %i] = False
self.handsplayers[player[1]]['street%dCBDone' %i] = False
+ #FIXME - Everything below this point is incomplete.
+ self.handsplayers[player[1]]['position'] = 2
+ self.handsplayers[player[1]]['tourneyTypeId'] = 1
+ self.handsplayers[player[1]]['startCards'] = 0
+ self.handsplayers[player[1]]['street0_3BChance'] = False
+ self.handsplayers[player[1]]['street0_3BDone'] = False
+ self.handsplayers[player[1]]['stealAttemptChance'] = False
+ self.handsplayers[player[1]]['stealAttempted'] = False
+ self.handsplayers[player[1]]['foldBbToStealChance'] = False
+ self.handsplayers[player[1]]['foldBbToStealChance'] = False
+ self.handsplayers[player[1]]['foldSbToStealChance'] = False
+ self.handsplayers[player[1]]['foldedSbToSteal'] = False
+ self.handsplayers[player[1]]['foldedBbToSteal'] = False
+ for i in range(1,5):
+ self.handsplayers[player[1]]['otherRaisedStreet%d' %i] = False
+ self.handsplayers[player[1]]['foldToOtherRaisedStreet%d' %i] = False
+ self.handsplayers[player[1]]['foldToStreet%dCBChance' %i] = False
+ self.handsplayers[player[1]]['foldToStreet%dCBDone' %i] = False
+ self.handsplayers[player[1]]['street%dCheckCallRaiseChance' %i] = False
+ self.handsplayers[player[1]]['street%dCheckCallRaiseDone' %i] = False
+
self.assembleHands(self.hand)
self.assembleHandsPlayers(self.hand)
@@ -114,7 +136,7 @@ class DerivedStats():
#hand.players = [[seat, name, chips],[seat, name, chips]]
for player in hand.players:
self.handsplayers[player[1]]['seatNo'] = player[0]
- self.handsplayers[player[1]]['startCash'] = player[2]
+ self.handsplayers[player[1]]['startCash'] = int(100 * Decimal(player[2]))
for i, street in enumerate(hand.actionStreets[2:]):
self.seen(self.hand, i+1)
@@ -134,9 +156,9 @@ class DerivedStats():
# Should be fine for split-pots, but won't be accurate for multi-way pots
self.handsplayers[player]['rake'] = int(100* hand.rake)/len(hand.collectees)
if self.handsplayers[player]['street1Seen'] == True:
- self.handsplayers[player]['wonWhenSeenStreet1'] = True
+ self.handsplayers[player]['wonWhenSeenStreet1'] = 1.0
if self.handsplayers[player]['sawShowdown'] == True:
- self.handsplayers[player]['wonAtSD'] = True
+ self.handsplayers[player]['wonAtSD'] = 1.0
for player in hand.pot.committed:
self.handsplayers[player]['totalProfit'] = int(self.handsplayers[player]['winnings'] - (100*hand.pot.committed[player]))
@@ -146,8 +168,11 @@ class DerivedStats():
for player in hand.players:
hcs = hand.join_holecards(player[1], asList=True)
hcs = hcs + [u'0x', u'0x', u'0x', u'0x', u'0x']
- for i, card in enumerate(hcs[:7], 1):
- self.handsplayers[player[1]]['card%s' % i] = Card.encodeCard(card)
+ #for i, card in enumerate(hcs[:7], 1): #Python 2.6 syntax
+ # self.handsplayers[player[1]]['card%s' % i] = Card.encodeCard(card)
+ for i, card in enumerate(hcs[:7]):
+ self.handsplayers[player[1]]['card%s' % (i+1)] = Card.encodeCard(card)
+
# position,
#Stud 3rd street card test
@@ -159,16 +184,6 @@ class DerivedStats():
# u.pressure: folds (Seat 1)
# 123smoothie: calls $0.02
# gashpor: calls $0.02
- # tourneyTypeId,
- # startCards,
- # street0_3BChance,street0_3BDone,
- # otherRaisedStreet1-4
- # foldToOtherRaisedStreet1-4
- # stealAttemptChance,stealAttempted,
- # foldBbToStealChance,foldedBbToSteal,
- # foldSbToStealChance,foldedSbToSteal,
- # foldToStreet1-4CBChance, foldToStreet1-4CBDone,
- # street1-4CheckCallRaiseChance, street1-4CheckCallRaiseDone,
# Additional stats
# 3betSB, 3betBB
@@ -253,13 +268,17 @@ class DerivedStats():
# Then no bets before the player with initiatives first action on current street
# ie. if player on street-1 had initiative
# and no donkbets occurred
- for i, street in enumerate(hand.actionStreets[2:], start=1):
- name = self.lastBetOrRaiser(hand.actionStreets[i])
+
+ # XXX: enumerate(list, start=x) is python 2.6 syntax; 'start'
+ # came there
+ #for i, street in enumerate(hand.actionStreets[2:], start=1):
+ for i, street in enumerate(hand.actionStreets[2:]):
+ name = self.lastBetOrRaiser(hand.actionStreets[i+1])
if name:
- chance = self.noBetsBefore(hand.actionStreets[i+1], name)
- self.handsplayers[name]['street%dCBChance' %i] = True
+ chance = self.noBetsBefore(hand.actionStreets[i+2], name)
+ self.handsplayers[name]['street%dCBChance' % (i+1)] = True
if chance == True:
- self.handsplayers[name]['street%dCBDone' %i] = self.betStreet(hand.actionStreets[i+1], name)
+ self.handsplayers[name]['street%dCBDone' % (i+1)] = self.betStreet(hand.actionStreets[i+2], name)
def seen(self, hand, i):
pas = set()
diff --git a/pyfpdb/Filters.py b/pyfpdb/Filters.py
index c74d5579..dc2e4859 100644
--- a/pyfpdb/Filters.py
+++ b/pyfpdb/Filters.py
@@ -479,7 +479,8 @@ class Filters(threading.Thread):
self.cursor.execute(self.sql.query['getLimits2'])
# selects limitType, bigBlind
result = self.db.cursor.fetchall()
- fl, nl = False, False
+ found = {'nl':False, 'fl':False, 'ring':False, 'tour':False}
+
if len(result) >= 1:
hbox = gtk.HBox(True, 0)
vbox1.pack_start(hbox, False, False, 0)
@@ -487,7 +488,6 @@ class Filters(threading.Thread):
hbox.pack_start(vbox2, False, False, 0)
vbox3 = gtk.VBox(False, 0)
hbox.pack_start(vbox3, False, False, 0)
- found = {'nl':False, 'fl':False, 'ring':False, 'tour':False}
for i, line in enumerate(result):
if "UseType" in self.display:
if line[0] != self.display["UseType"]:
diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py
index 7db420c7..16131ab2 100755
--- a/pyfpdb/GuiBulkImport.py
+++ b/pyfpdb/GuiBulkImport.py
@@ -326,6 +326,8 @@ def main(argv=None):
help="How often to print a one-line status report (0 (default) means never)")
parser.add_option("-u", "--usage", action="store_true", dest="usage", default=False,
help="Print some useful one liners")
+ parser.add_option("-s", "--starsarchive", action="store_true", dest="starsArchive", default=False,
+ help="Do the required conversion for Stars Archive format (ie. as provided by support")
(options, argv) = parser.parse_args(args = argv)
if options.usage == True:
@@ -369,6 +371,8 @@ def main(argv=None):
importer.setThreads(-1)
importer.addBulkImportImportFileOrDir(os.path.expanduser(options.filename), site=options.filtername)
importer.setCallHud(False)
+ if options.starsArchive:
+ importer.setStarsArchive(True)
(stored, dups, partial, errs, ttime) = importer.runImport()
importer.clearFileList()
print 'GuiBulkImport done: Stored: %d \tDuplicates: %d \tPartial: %d \tErrors: %d in %s seconds - %.0f/sec'\
diff --git a/pyfpdb/HUD_config.xml.example b/pyfpdb/HUD_config.xml.example
index b0f26c53..b1ebd761 100644
--- a/pyfpdb/HUD_config.xml.example
+++ b/pyfpdb/HUD_config.xml.example
@@ -387,6 +387,18 @@ Left-Drag to Move"
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py
index 9ff78249..3467216a 100644
--- a/pyfpdb/Hand.py
+++ b/pyfpdb/Hand.py
@@ -54,7 +54,10 @@ class Hand(object):
self.starttime = 0
self.handText = handText
self.handid = 0
+ self.cancelled = False
self.dbid_hands = 0
+ self.dbid_pids = None
+ self.dbid_gt = 0
self.tablename = ""
self.hero = ""
self.maxseats = None
@@ -189,22 +192,21 @@ dealt whether they were seen in a 'dealt to' line
self.holecards[street][player] = [open, closed]
def prepInsert(self, db):
- pass
+ #####
+ # Players, Gametypes, TourneyTypes are all shared functions that are needed for additional tables
+ # These functions are intended for prep insert eventually
+ #####
+ # Players - base playerid and siteid tuple
+ self.dbid_pids = db.getSqlPlayerIDs([p[1] for p in self.players], self.siteId)
+
+ #Gametypes
+ self.dbid_gt = db.getGameTypeId(self.siteId, self.gametype)
def insert(self, db):
""" Function to insert Hand into database
Should not commit, and do minimal selects. Callers may want to cache commits
db: a connected fpdb_db object"""
- #####
- # Players, Gametypes, TourneyTypes are all shared functions that are needed for additional tables
- # These functions are intended for prep insert eventually
- #####
- # Players - base playerid and siteid tuple
- sqlids = db.getSqlPlayerIDs([p[1] for p in self.players], self.siteId)
-
- #Gametypes
- gtid = db.getGameTypeId(self.siteId, self.gametype)
self.stats.getStats(self)
@@ -213,14 +215,14 @@ db: a connected fpdb_db object"""
#####
hh = self.stats.getHands()
- if not db.isDuplicate(gtid, hh['siteHandNo']):
+ if not db.isDuplicate(self.dbid_gt, hh['siteHandNo']):
# Hands - Summary information of hand indexed by handId - gameinfo
- hh['gameTypeId'] = gtid
+ hh['gameTypeId'] = self.dbid_gt
# seats TINYINT NOT NULL,
- hh['seats'] = len(sqlids)
+ hh['seats'] = len(self.dbid_pids)
self.dbid_hands = db.storeHand(hh)
- db.storeHandsPlayers(self.dbid_hands, sqlids, self.stats.getHandsPlayers())
+ db.storeHandsPlayers(self.dbid_hands, self.dbid_pids, self.stats.getHandsPlayers())
# HandsActions - all actions for all players for all streets - self.actions
# HudCache data can be generated from HandsActions (HandsPlayers?)
# Tourneys ?
@@ -262,6 +264,9 @@ If a player has None chips he won't be added."""
log.debug("markStreets:\n"+ str(self.streets))
else:
log.error("markstreets didn't match")
+ log.error(" - Assuming hand cancelled")
+ self.cancelled = True
+ raise FpdbParseError
def checkPlayerExists(self,player):
if player not in [p[1] for p in self.players]:
@@ -612,6 +617,8 @@ class HoldemOmahaHand(Hand):
hhc.readPlayerStacks(self)
hhc.compilePlayerRegexs(self)
hhc.markStreets(self)
+ if self.cancelled:
+ return
hhc.readBlinds(self)
hhc.readAntes(self)
hhc.readButton(self)
diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py
index 27bb9b1a..a18797df 100644
--- a/pyfpdb/HandHistoryConverter.py
+++ b/pyfpdb/HandHistoryConverter.py
@@ -57,7 +57,7 @@ class HandHistoryConverter():
codepage = "cp1252"
- def __init__(self, in_path = '-', out_path = '-', follow=False, index=0, autostart=True):
+ def __init__(self, in_path = '-', out_path = '-', follow=False, index=0, autostart=True, starsArchive=False):
"""\
in_path (default '-' = sys.stdin)
out_path (default '-' = sys.stdout)
@@ -66,6 +66,7 @@ follow : whether to tail -f the input"""
log.info("HandHistory init - %s subclass, in_path '%s'; out_path '%s'" % (self.sitename, in_path, out_path) )
self.index = 0
+ self.starsArchive = starsArchive
self.in_path = in_path
self.out_path = out_path
@@ -254,6 +255,11 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py.
self.readFile()
self.obs = self.obs.strip()
self.obs = self.obs.replace('\r\n', '\n')
+ if self.starsArchive == True:
+ log.debug("Converting starsArchive format to readable")
+ m = re.compile('^Hand #\d+', re.MULTILINE)
+ self.obs = m.sub('', self.obs)
+
if self.obs is None or self.obs == "":
log.info("Read no hands.")
return []
diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py
index 5a0d1965..56c1f388 100644
--- a/pyfpdb/SQL.py
+++ b/pyfpdb/SQL.py
@@ -2789,8 +2789,6 @@ class Sql:
,hp.tourneyTypeId
,date_format(h.handStart, 'd%y%m%d')
"""
-#>>>>>>> 28ca49d592c8e706ad6ee58dd26655bcc33fc5fb:pyfpdb/SQL.py
-#"""
elif db_server == 'postgresql':
self.query['rebuildHudCache'] = """
INSERT INTO HudCache
@@ -3327,8 +3325,106 @@ class Sql:
%s, %s, %s, %s, %s, %s, %s, %s, %s)"""
-
-
+ self.query['store_hands_players'] = """INSERT INTO HandsPlayers (
+ handId,
+ playerId,
+ startCash,
+ seatNo,
+ card1,
+ card2,
+ card3,
+ card4,
+ card5,
+ card6,
+ card7,
+ winnings,
+ rake,
+ totalProfit,
+ street0VPI,
+ street1Seen,
+ street2Seen,
+ street3Seen,
+ street4Seen,
+ sawShowdown,
+ wonAtSD,
+ street0Aggr,
+ street1Aggr,
+ street2Aggr,
+ street3Aggr,
+ street4Aggr,
+ street1CBChance,
+ street2CBChance,
+ street3CBChance,
+ street4CBChance,
+ street1CBDone,
+ street2CBDone,
+ street3CBDone,
+ street4CBDone,
+ wonWhenSeenStreet1,
+ street0Calls,
+ street1Calls,
+ street2Calls,
+ street3Calls,
+ street4Calls,
+ street0Bets,
+ street1Bets,
+ street2Bets,
+ street3Bets,
+ street4Bets,
+ position,
+ tourneyTypeId,
+ startCards,
+ street0_3BChance,
+ street0_3BDone,
+ otherRaisedStreet1,
+ otherRaisedStreet2,
+ otherRaisedStreet3,
+ otherRaisedStreet4,
+ foldToOtherRaisedStreet1,
+ foldToOtherRaisedStreet2,
+ foldToOtherRaisedStreet3,
+ foldToOtherRaisedStreet4,
+ stealAttemptChance,
+ stealAttempted,
+ foldBbToStealChance,
+ foldedBbToSteal,
+ foldSbToStealChance,
+ foldedSbToSteal,
+ foldToStreet1CBChance,
+ foldToStreet1CBDone,
+ foldToStreet2CBChance,
+ foldToStreet2CBDone,
+ foldToStreet3CBChance,
+ foldToStreet3CBDone,
+ foldToStreet4CBChance,
+ foldToStreet4CBDone,
+ street1CheckCallRaiseChance,
+ street1CheckCallRaiseDone,
+ street2CheckCallRaiseChance,
+ street2CheckCallRaiseDone,
+ street3CheckCallRaiseChance,
+ street3CheckCallRaiseDone,
+ street4CheckCallRaiseChance,
+ street4CheckCallRaiseDone
+ )
+ VALUES (
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s, %s
+ )"""
if db_server == 'mysql':
self.query['placeholder'] = u'%s'
diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py
index e93c9c03..bff044d5 100755
--- a/pyfpdb/fpdb.py
+++ b/pyfpdb/fpdb.py
@@ -237,7 +237,8 @@ class fpdb:
dia.set_comments("GTK AboutDialog comments here")
dia.set_license("GPL v3")
dia.set_website("http://fpdb.sourceforge.net/")
- dia.set_authors("Steffen, Eratosthenes, s0rrow, EricBlade, _mt, sqlcoder, Bostik, and others")
+ dia.set_authors(['Steffen', 'Eratosthenes', 's0rrow',
+ 'EricBlade', '_mt', 'sqlcoder', 'Bostik', 'and others'])
dia.set_program_name("Free Poker Database (FPDB)")
db_version = ""
diff --git a/pyfpdb/fpdb_db.py b/pyfpdb/fpdb_db.py
index baabb4bf..2d7f2e0c 100644
--- a/pyfpdb/fpdb_db.py
+++ b/pyfpdb/fpdb_db.py
@@ -158,7 +158,7 @@ class fpdb_db:
if not os.path.isdir(Configuration.DIR_DATABASES) and not database == ":memory:":
print "Creating directory: '%s'" % (Configuration.DIR_DATABASES)
os.mkdir(Configuration.DIR_DATABASES)
- database = os.path.join(Configuration.DIR_DATABASE, database)
+ database = os.path.join(Configuration.DIR_DATABASES, database)
self.db = sqlite3.connect(database, detect_types=sqlite3.PARSE_DECLTYPES )
sqlite3.register_converter("bool", lambda x: bool(int(x)))
sqlite3.register_adapter(bool, lambda x: "1" if x else "0")
diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py
index 760e1f01..8921d9d8 100644
--- a/pyfpdb/fpdb_import.py
+++ b/pyfpdb/fpdb_import.py
@@ -91,6 +91,7 @@ class Importer:
self.settings.setdefault("writeQMaxWait", 10) # not used
self.settings.setdefault("dropIndexes", "don't drop")
self.settings.setdefault("dropHudCache", "don't drop")
+ self.settings.setdefault("starsArchive", False)
self.writeq = None
self.database = Database.Database(self.config, sql = self.sql)
@@ -134,6 +135,9 @@ class Importer:
def setDropHudCache(self, value):
self.settings['dropHudCache'] = value
+ def setStarsArchive(self, value):
+ self.settings['starsArchive'] = value
+
# def setWatchTime(self):
# self.updated = time()
@@ -425,23 +429,30 @@ class Importer:
mod = __import__(filter)
obj = getattr(mod, filter_name, None)
if callable(obj):
- hhc = obj(in_path = file, out_path = out_path, index = 0) # Index into file 0 until changeover
+ hhc = obj(in_path = file, out_path = out_path, index = 0, starsArchive = self.settings['starsArchive']) # Index into file 0 until changeover
if hhc.getStatus() and self.NEWIMPORT == False:
(stored, duplicates, partial, errors, ttime) = self.import_fpdb_file(db, out_path, site, q)
elif hhc.getStatus() and self.NEWIMPORT == True:
#This code doesn't do anything yet
handlist = hhc.getProcessedHands()
self.pos_in_file[file] = hhc.getLastCharacterRead()
+ to_hud = []
for hand in handlist:
- #try, except duplicates here?
- #hand.prepInsert()
- hand.insert(self.database)
- if self.callHud and hand.dbid_hands != 0:
- #print "DEBUG: call to HUD: handsId: %s" % hand.dbid_hands
- #pipe the Hands.id out to the HUD
- # print "fpdb_import: sending hand to hud", handsId, "pipe =", self.caller.pipe_to_hud
- self.caller.pipe_to_hud.stdin.write("%s" % (hand.dbid_hands) + os.linesep)
+ if hand is not None:
+ #try, except duplicates here?
+ hand.prepInsert(self.database)
+ hand.insert(self.database)
+ if self.callHud and hand.dbid_hands != 0:
+ to_hud.append(hand.dbid_hands)
+ else:
+ log.error("Hand processed but empty")
+ self.database.commit()
+
+ #pipe the Hands.id out to the HUD
+ for hid in to_hud:
+ 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)
errors = getattr(hhc, 'numErrors')
stored = getattr(hhc, 'numHands')
diff --git a/pyfpdb/regression-test-files/cash/Stars/Flop/LO8-6max-USD-0.05-0.10-20090315.Hand-cancelled.txt b/pyfpdb/regression-test-files/cash/Stars/Flop/LO8-6max-USD-0.05-0.10-20090315.Hand-cancelled.txt
new file mode 100644
index 00000000..9959180c
--- /dev/null
+++ b/pyfpdb/regression-test-files/cash/Stars/Flop/LO8-6max-USD-0.05-0.10-20090315.Hand-cancelled.txt
@@ -0,0 +1,11 @@
+PokerStars Game #25979907808: Omaha Pot Limit ($0.05/$0.10 USD) - 2009/03/15 6:20:33 ET
+Table 'Waterman' 6-max Seat #1 is the button
+Seat 1: s0rrow ($11.65 in chips)
+s0rrow: posts small blind $0.05
+ritalinIV: is sitting out
+Hand cancelled
+*** SUMMARY ***
+Seat 1: s0rrow (button) collected ($0)
+
+
+