From 2fd856d55bd93db87d23bead009dfd2c29e52d56 Mon Sep 17 00:00:00 2001 From: Worros Date: Tue, 3 Aug 2010 18:24:03 +0800 Subject: [PATCH 1/4] HHC: Shorten length of time hh file is open by 2 lines --- pyfpdb/HandHistoryConverter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 59ba90ef..8faf5dfb 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -433,9 +433,9 @@ or None if we fail to get the info """ try: in_fh = codecs.open(self.in_path, 'r', kodec) whole_file = in_fh.read() + in_fh.close() self.obs = whole_file[self.index:] self.index = len(whole_file) - in_fh.close() break except: pass From 9329475298546c95993cb7578acb84c09d8a3d47 Mon Sep 17 00:00:00 2001 From: Worros Date: Tue, 3 Aug 2010 19:22:52 +0800 Subject: [PATCH 2/4] Stars: Take 42 on Tourney parsing Hopefully fix parsing for bounty and cash tourneys for good. FPP is probably still broken --- pyfpdb/PokerStarsToFpdb.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 1e71c39e..80d48b6b 100644 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -72,7 +72,7 @@ class PokerStars(HandHistoryConverter): (Tournament\s\# # open paren of tournament info (?P\d+),\s # here's how I plan to use LS - (?P(?P[%(LS)s\d\.]+)?\+?(?P[%(LS)s\d\.]+)?\+?(?P[%(LS)s\d\.]+)\s?(?P%(LEGAL_ISO)s)?|Freeroll)\s+)? + (?P(?P[%(LS)s\d\.]+)?\+(?P[%(LS)s\d\.]+)?\+?(?P[%(LS)s\d\.]+)?\s?(?P%(LEGAL_ISO)s)?|Freeroll)\s+)? # close paren of tournament info (?PHORSE|8\-Game|HOSE)?\s?\(? (?PHold\'em|Razz|RAZZ|7\sCard\sStud|7\sCard\sStud\sHi/Lo|Omaha|Omaha\sHi/Lo|Badugi|Triple\sDraw\s2\-7\sLowball|5\sCard\sDraw)\s @@ -252,14 +252,20 @@ class PokerStars(HandHistoryConverter): raise FpdbParseError("failed to detect currency") if hand.buyinCurrency!="PSFP": - hand.buyin = int(100*Decimal(info['BIAMT'][1:])) - if info['BIRAKE'][0]!="$": #we have a non-bounty game - info['BOUNTY']=info['BOUNTY']+info['BIRAKE'] #TODO remove this dirty dirty hack by fixing regex - hand.fee = int(100*Decimal(info['BOUNTY'][1:])) - else: - hand.fee = int(100*Decimal(info['BIRAKE'][1:])) - hand.isKO = True - hand.koBounty = int(100*Decimal(info['BOUNTY'][1:])) + if info['BOUNTY'] != None: + # There is a bounty, Which means we need to switch BOUNTY and BIRAKE values + tmp = info['BOUNTY'] + info['BOUNTY'] = info['BIRAKE'] + info['BIRAKE'] = tmp + info['BOUNTY'] = info['BOUNTY'].strip(u'$€') # Strip here where it isn't 'None' + hand.koBounty = int(100*Decimal(info['BOUNTY'])) + + info['BIAMT'] = info['BIAMT'].strip(u'$€') + info['BIRAKE'] = info['BIRAKE'].strip(u'$€') + + hand.buyin = int(100*Decimal(info['BIAMT'])) + hand.fee = int(100*Decimal(info['BIRAKE'])) + hand.isKO = True else: hand.buyin = int(Decimal(info[key][0:-3])) hand.fee = 0 From 53c796dddce18ddc3cca159103c73ddfac6fcf38 Mon Sep 17 00:00:00 2001 From: Worros Date: Tue, 3 Aug 2010 19:27:34 +0800 Subject: [PATCH 3/4] Importer: Add excetion handler to hud call. Had a report on the 2+2 thread that: File "C:\Documents and Settings\b\Desktop\fpdb\pyfpdb\GuiAutoImport.py", line 160, in do_import self.importer.runUpdated() File "C:\Documents and Settings\b\Desktop\fpdb\pyfpdb\fpdb_import.py", line 371, in runUpdated (stored, duplicates, partial, errors, ttime) = self.import_file_dict(self.database, file, self.filelist[file][0], self.filelist[file][1], None) File "C:\Documents and Settings\b\Desktop\fpdb\pyfpdb\fpdb_import.py", line 467, in import_file_dict print "fpdb_import: sending hand to hud", hand.dbid_hands, "pipe =", self.caller.pipe_to_hud IOError: [Errno 9] Bad file descriptor Was happening, which is a crash attempting to print self.caller.pipe_to_hud This patch doesn't fix the problem, but should give some indication in the log that it happened. --- pyfpdb/fpdb_import.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index eeaa63ac..cbe87684 100755 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -464,8 +464,11 @@ class Importer: #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) + 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') From dc2b315a9f7078783ff9a71b55561560d66ff6da Mon Sep 17 00:00:00 2001 From: Worros Date: Tue, 3 Aug 2010 19:52:49 +0800 Subject: [PATCH 4/4] Stars: Fix FPP tourneys (maybe...) Also move hand.isKO to the correct place --- pyfpdb/PokerStarsToFpdb.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index 80d48b6b..384f5082 100644 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -72,7 +72,7 @@ class PokerStars(HandHistoryConverter): (Tournament\s\# # open paren of tournament info (?P\d+),\s # here's how I plan to use LS - (?P(?P[%(LS)s\d\.]+)?\+(?P[%(LS)s\d\.]+)?\+?(?P[%(LS)s\d\.]+)?\s?(?P%(LEGAL_ISO)s)?|Freeroll)\s+)? + (?P(?P[%(LS)s\d\.]+)?\+?(?P[%(LS)s\d\.]+)?\+?(?P[%(LS)s\d\.]+)?\s?(?P%(LEGAL_ISO)s)?|Freeroll)\s+)? # close paren of tournament info (?PHORSE|8\-Game|HOSE)?\s?\(? (?PHold\'em|Razz|RAZZ|7\sCard\sStud|7\sCard\sStud\sHi/Lo|Omaha|Omaha\sHi/Lo|Badugi|Triple\sDraw\s2\-7\sLowball|5\sCard\sDraw)\s @@ -250,6 +250,8 @@ class PokerStars(HandHistoryConverter): else: #FIXME: handle other currencies, FPP, play money raise FpdbParseError("failed to detect currency") + + info['BIAMT'] = info['BIAMT'].strip(u'$€FPP') if hand.buyinCurrency!="PSFP": if info['BOUNTY'] != None: @@ -259,15 +261,14 @@ class PokerStars(HandHistoryConverter): info['BIRAKE'] = tmp info['BOUNTY'] = info['BOUNTY'].strip(u'$€') # Strip here where it isn't 'None' hand.koBounty = int(100*Decimal(info['BOUNTY'])) + hand.isKO = True - info['BIAMT'] = info['BIAMT'].strip(u'$€') info['BIRAKE'] = info['BIRAKE'].strip(u'$€') hand.buyin = int(100*Decimal(info['BIAMT'])) hand.fee = int(100*Decimal(info['BIRAKE'])) - hand.isKO = True else: - hand.buyin = int(Decimal(info[key][0:-3])) + hand.buyin = int(Decimal(info['BIAMT'])) hand.fee = 0 if key == 'LEVEL': hand.level = info[key]