From 9cf75f7303c4fe73fc3647a1198d5f4aac2cf1a1 Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 1 Feb 2010 08:47:55 -0500 Subject: [PATCH 1/8] fix getTableTitleRe calling in HUD_main:read_stdin, to use site_name (currently processing site name) instead of "site" which was always last site_name on list (this may break some people's HHC's, now that it works right) --- pyfpdb/HUD_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index df144e92..71b7c03e 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -268,7 +268,7 @@ class HUD_main(object): cards['common'] = comm_cards['common'] table_kwargs = dict(table_name = table_name, tournament = tour_number, table_number = tab_number) - search_string = getTableTitleRe(self.config, site, type, **table_kwargs) + search_string = getTableTitleRe(self.config, site_name, type, **table_kwargs) tablewindow = Tables.Table(search_string, **table_kwargs) if tablewindow is None: From 27f95c51b2670f42767a4d469e36d1dda4ce97e9 Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 1 Feb 2010 08:48:28 -0500 Subject: [PATCH 2/8] whitespace --- pyfpdb/HandHistoryConverter.py | 47 ++++++++++++++++------------------ 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index bec2ebae..9047af50 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -64,7 +64,7 @@ out_path (default '-' = sys.stdout) 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 = index self.starsArchive = starsArchive @@ -77,7 +77,7 @@ follow : whether to tail -f the input""" # Tourney object used to store TourneyInfo when called to deal with a Summary file self.tourney = None - + if in_path == '-': self.in_fh = sys.stdin @@ -106,7 +106,7 @@ follow : whether to tail -f the input""" self.follow = follow self.compiledPlayers = set() self.maxseats = 10 - + self.status = True self.parsedObjectType = "HH" #default behaviour : parsing HH files, can be "Summary" if the parsing encounters a Summary File @@ -121,7 +121,7 @@ HandHistoryConverter: '%(sitename)s' in_path '%(in_path)s' out_path '%(out_path)s' follow '%(follow)s' - """ % locals() + """ % locals() def start(self): """Process a hand at a time from the input specified by in_path. @@ -141,7 +141,7 @@ Otherwise, finish at EOF. self.numHands = 0 self.numErrors = 0 if self.follow: - #TODO: See how summary files can be handled on the fly (here they should be rejected as before) + #TODO: See how summary files can be handled on the fly (here they should be rejected as before) log.info("Tailing '%s'" % self.in_path) for handText in self.tailHands(): try: @@ -176,7 +176,7 @@ Otherwise, finish at EOF. endtime = time.time() if summaryParsingStatus : log.info("Summary file '%s' correctly parsed (took %.3f seconds)" % (self.in_path, endtime - starttime)) - else : + else : log.warning("Error converting summary file '%s' (took %.3f seconds)" % (self.in_path, endtime - starttime)) except IOError, ioe: @@ -230,7 +230,7 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py. # x-- [x,--,] x,-- # x--x [x,--,x] x,x # x--x-- [x,--,x,--,] x,x,-- - + # The length is always odd. # 'odd' indices are always splitters. # 'even' indices are always paragraphs or '' @@ -264,13 +264,13 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py. log.info("Read no hands.") return [] return re.split(self.re_SplitHands, self.obs) - + def processHand(self, handText): gametype = self.determineGameType(handText) log.debug("gametype %s" % gametype) hand = None l = None - if gametype is None: + if gametype is None: gametype = "unmatched" # TODO: not ideal, just trying to not error. # TODO: Need to count failed hands. @@ -304,7 +304,7 @@ which it expects to find at self.re_TailSplitHands -- see for e.g. Everleaf.py. # This function should return a list of lists looking like: # return [["ring", "hold", "nl"], ["tour", "hold", "nl"]] # Showing all supported games limits and types - + def readSupportedGames(self): abstract # should return a list @@ -339,17 +339,17 @@ or None if we fail to get the info """ # Needs to return a list of lists in the format # [['seat#', 'player1name', 'stacksize'] ['seat#', 'player2name', 'stacksize'] [...]] def readPlayerStacks(self, hand): abstract - + def compilePlayerRegexs(self): abstract """Compile dynamic regexes -- these explicitly match known player names and must be updated if a new player joins""" - + # Needs to return a MatchObject with group names identifying the streets into the Hand object # so groups are called by street names 'PREFLOP', 'FLOP', 'STREET2' etc # blinds are done seperately def markStreets(self, hand): abstract #Needs to return a list in the format - # ['player1name', 'player2name', ...] where player1name is the sb and player2name is bb, + # ['player1name', 'player2name', ...] where player1name is the sb and player2name is bb, # addtional players are assumed to post a bb oop def readBlinds(self, hand): abstract def readAntes(self, hand): abstract @@ -362,16 +362,16 @@ or None if we fail to get the info """ def readShownCards(self, hand): abstract # Some sites do odd stuff that doesn't fall in to the normal HH parsing. - # e.g., FTP doesn't put mixed game info in the HH, but puts in in the + # e.g., FTP doesn't put mixed game info in the HH, but puts in in the # file name. Use readOther() to clean up those messes. def readOther(self, hand): pass - + # Some sites don't report the rake. This will be called at the end of the hand after the pot total has been calculated # an inheriting class can calculate it for the specific site if need be. def getRake(self, hand): hand.rake = hand.totalpot - hand.totalcollected # * Decimal('0.05') # probably not quite right - - + + def sanityCheck(self): """Check we aren't going to do some stupid things""" #TODO: the hhbase stuff needs to be in fpdb_import @@ -396,7 +396,7 @@ or None if we fail to get the info """ # Make sure input and output files are different or we'll overwrite the source file if True: # basically.. I don't know sane = True - + if self.in_path != '-' and self.out_path == self.in_path: print "HH Sanity Check: output and input files are the same, check config" sane = False @@ -429,7 +429,7 @@ or None if we fail to get the info """ def readFile(self): """Open in_path according to self.codepage. Exceptions caught further up""" - + if self.filetype == "text": if self.in_path == '-': # read from stdin @@ -464,7 +464,7 @@ or None if we fail to get the info """ if hand.gametype['base'] == 'stud': if mo <= 8: return 8 - else: return mo + else: return mo if hand.gametype['base'] == 'draw': if mo <= 6: return 6 @@ -500,9 +500,9 @@ or None if we fail to get the info """ def getParsedObjectType(self): return self.parsedObjectType - #returns a status (True/False) indicating wether the parsing could be done correctly or not + #returns a status (True/False) indicating wether the parsing could be done correctly or not def readSummaryInfo(self, summaryInfoList): abstract - + def getTourney(self): return self.tourney @@ -525,6 +525,3 @@ def getSiteHhc(config, sitename): hhcName = config.supported_sites[sitename].converter hhcModule = __import__(hhcName) return getattr(hhcModule, hhcName[:-6]) - - - From 1656a0e6d1933b72198bc5bdfadd7d4275036f54 Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 1 Feb 2010 08:51:06 -0500 Subject: [PATCH 3/8] Everleaf: adjust Everleaf regexs to support tournaments, add error printing on failure of compilePlayerRegexs, add ring omahahilo pl and tour hold nl to supported games list, determine tournament number/table number from processing filename, fix getTableTitleRe --- pyfpdb/EverleafToFpdb.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index ad9d0524..c9206ea5 100755 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -38,8 +38,9 @@ class Everleaf(HandHistoryConverter): #re.compile(ur"^(Blinds )?(?P\$| €|)(?P[.0-9]+)/(?:\$| €)?(?P[.0-9]+) (?PNL|PL|) (?P(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE) re_HandInfo = re.compile(ur".*#(?P[0-9]+)\n.*\n(Blinds )?(?:\$| €|)(?P[.0-9]+)/(?:\$| €|)(?P[.0-9]+) (?P.*) - (?P\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P.+$)", re.MULTILINE) re_Button = re.compile(ur"^Seat (?P
[0-9]+)\.txt") def compilePlayerRegexs(self, hand): @@ -55,18 +56,25 @@ class Everleaf(HandHistoryConverter): self.re_Antes = re.compile(ur"^%s: posts ante \[(?:\$| €|) (?P[.0-9]+)" % player_re, re.MULTILINE) self.re_BringIn = re.compile(ur"^%s posts bring-in (?:\$| €|)(?P[.0-9]+)\." % player_re, re.MULTILINE) self.re_HeroCards = re.compile(ur"^Dealt to %s \[ (?P.*) \]" % player_re, re.MULTILINE) - self.re_Action = re.compile(ur"^%s(?P: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P[.\d]+) (USD|EUR|)\])?" % player_re, re.MULTILINE) + self.re_Action = re.compile(ur"^%s(?P: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P[.,\d]+) (USD|EUR|Chips)\])?" % player_re, re.MULTILINE) #self.re_Action = re.compile(ur"^%s(?P: bets| checks| raises| calls| folds| complete to)(\s\[?(?:\$| €|) ?(?P\d+\.?\d*)\.?\s?(USD|EUR|)\]?)?" % player_re, re.MULTILINE) self.re_ShowdownAction = re.compile(ur"^%s shows \[ (?P.*) \]" % player_re, re.MULTILINE) self.re_CollectPot = re.compile(ur"^%s wins (?:\$| €|) (?P[.\d]+) (USD|EUR|chips)(.*?\[ (?P.*?) \])?" % player_re, re.MULTILINE) self.re_SitsOut = re.compile(ur"^%s sits out" % player_re, re.MULTILINE) + else: + print "*** EverleafToFpdb: compilePlayerRegexs failed" + print players + print self.compiledPlayers + def readSupportedGames(self): return [["ring", "hold", "nl"], ["ring", "hold", "pl"], ["ring", "hold", "fl"], ["ring", "studhi", "fl"], - ["ring", "omahahi", "pl"] + ["ring", "omahahi", "pl"], + ["ring", "omahahilo", "pl"], + ["tour", "hold", "nl"] ] def determineGameType(self, handText): @@ -138,6 +146,13 @@ or None if we fail to get the info """ hand.tablename = m.group('TABLE') hand.maxseats = 6 # assume 6-max unless we have proof it's a larger/smaller game, since everleaf doesn't give seat max info + t = self.re_TourneyInfoFromFilename.search(self.in_path) + if t: + tourno = t.group('TOURNO') + if tourno: # we're a tourney, yay + hand.tourNo = tourno + hand.tablename = t.group('TABLE') + # Believe Everleaf time is GMT/UTC, no transation necessary # Stars format (Nov 10 2008): 2008/11/07 12:38:49 CET [2008/11/07 7:38:49 ET] # or : 2008/11/07 12:38:49 ET @@ -287,7 +302,9 @@ or None if we fail to get the info """ @staticmethod def getTableTitleRe(type, table_name=None, tournament = None, table_number=None): - return "^%s -" % (table_name) + if tournament: + return "%s - Tournament ID: %s -" % (table_number, tournament) + return "%s -" % (table_name) From e3be7db2a0631d875188b6ee22855535b8694f18 Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 1 Feb 2010 09:17:42 -0500 Subject: [PATCH 4/8] fix bug i introduced that caused everleaf cash hands to fail --- pyfpdb/EverleafToFpdb.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index c9206ea5..fe17f158 100755 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -149,7 +149,6 @@ or None if we fail to get the info """ t = self.re_TourneyInfoFromFilename.search(self.in_path) if t: tourno = t.group('TOURNO') - if tourno: # we're a tourney, yay hand.tourNo = tourno hand.tablename = t.group('TABLE') From 81ff8e632cc483b0cc53678dd0c818734c8d7e7e Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 1 Feb 2010 09:41:33 -0500 Subject: [PATCH 5/8] remove my misunderstanding of how compileplayerregexs worked --- pyfpdb/EverleafToFpdb.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index fe17f158..fdc35bf6 100755 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -62,11 +62,6 @@ class Everleaf(HandHistoryConverter): self.re_CollectPot = re.compile(ur"^%s wins (?:\$| €|) (?P[.\d]+) (USD|EUR|chips)(.*?\[ (?P.*?) \])?" % player_re, re.MULTILINE) self.re_SitsOut = re.compile(ur"^%s sits out" % player_re, re.MULTILINE) - else: - print "*** EverleafToFpdb: compilePlayerRegexs failed" - print players - print self.compiledPlayers - def readSupportedGames(self): return [["ring", "hold", "nl"], ["ring", "hold", "pl"], From eff216919dd7ad03bdfe9a7500438c1c46ac6a80 Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Mon, 1 Feb 2010 09:57:28 -0500 Subject: [PATCH 6/8] Everleaf: Change "EUR"(old) to "EURO"(new), still doesn't seem to allow eur import (is that because my site config is set for usd ?) --- pyfpdb/EverleafToFpdb.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index fdc35bf6..5dd8d041 100755 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -38,7 +38,7 @@ class Everleaf(HandHistoryConverter): #re.compile(ur"^(Blinds )?(?P\$| €|)(?P[.0-9]+)/(?:\$| €)?(?P[.0-9]+) (?PNL|PL|) (?P(Hold\'em|Omaha|7 Card Stud))", re.MULTILINE) re_HandInfo = re.compile(ur".*#(?P[0-9]+)\n.*\n(Blinds )?(?:\$| €|)(?P[.0-9]+)/(?:\$| €|)(?P[.0-9]+) (?P.*) - (?P\d\d\d\d/\d\d/\d\d - \d\d:\d\d:\d\d)\nTable (?P
.+$)", re.MULTILINE) re_Button = re.compile(ur"^Seat (?P
[0-9]+)\.txt") @@ -56,10 +56,10 @@ class Everleaf(HandHistoryConverter): self.re_Antes = re.compile(ur"^%s: posts ante \[(?:\$| €|) (?P[.0-9]+)" % player_re, re.MULTILINE) self.re_BringIn = re.compile(ur"^%s posts bring-in (?:\$| €|)(?P[.0-9]+)\." % player_re, re.MULTILINE) self.re_HeroCards = re.compile(ur"^Dealt to %s \[ (?P.*) \]" % player_re, re.MULTILINE) - self.re_Action = re.compile(ur"^%s(?P: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P[.,\d]+) (USD|EUR|Chips)\])?" % player_re, re.MULTILINE) + self.re_Action = re.compile(ur"^%s(?P: bets| checks| raises| calls| folds)(\s\[(?:\$| €|) (?P[.,\d]+) (USD|EURO|Chips)\])?" % player_re, re.MULTILINE) #self.re_Action = re.compile(ur"^%s(?P: bets| checks| raises| calls| folds| complete to)(\s\[?(?:\$| €|) ?(?P\d+\.?\d*)\.?\s?(USD|EUR|)\]?)?" % player_re, re.MULTILINE) self.re_ShowdownAction = re.compile(ur"^%s shows \[ (?P.*) \]" % player_re, re.MULTILINE) - self.re_CollectPot = re.compile(ur"^%s wins (?:\$| €|) (?P[.\d]+) (USD|EUR|chips)(.*?\[ (?P.*?) \])?" % player_re, re.MULTILINE) + self.re_CollectPot = re.compile(ur"^%s wins (?:\$| €|) (?P[.\d]+) (USD|EURO|chips)(.*?\[ (?P.*?) \])?" % player_re, re.MULTILINE) self.re_SitsOut = re.compile(ur"^%s sits out" % player_re, re.MULTILINE) def readSupportedGames(self): From 76f9517655da8881aaabef57996f80254d1a60c2 Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Tue, 2 Feb 2010 14:54:27 -0500 Subject: [PATCH 7/8] WinTables will no longer accept trying to attach to "FPDBHUD" titled windows --- pyfpdb/WinTables.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyfpdb/WinTables.py b/pyfpdb/WinTables.py index f834eac9..5bca9e41 100644 --- a/pyfpdb/WinTables.py +++ b/pyfpdb/WinTables.py @@ -50,10 +50,12 @@ class Table(Table_Window): titles = {} win32gui.EnumWindows(win_enum_handler, titles) for hwnd in titles: + # print "searching ", search_string, " in ", titles[hwnd] if re.search(search_string, titles[hwnd]): if 'History for table:' in titles[hwnd]: continue # Everleaf Network HH viewer window if 'HUD:' in titles[hwnd]: continue # FPDB HUD window if 'Chat:' in titles[hwnd]: continue # Some sites (FTP? PS? Others?) have seperable or seperately constructed chat windows + if 'FPDBHUD' in titles[hwnd]: continue # can't attach to ourselves! self.window = hwnd break From c10665935fba50b1844cddda23f3dd7bde2beff4 Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Thu, 4 Feb 2010 16:33:21 -0500 Subject: [PATCH 8/8] stop clobbering search_string in TableWindow::__init__ . Thanks Ray! --- pyfpdb/HUD_main.py | 1 + pyfpdb/TableWindow.py | 22 +++++++++++----------- pyfpdb/WinTables.py | 1 + 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index 1251c2f0..0a365850 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -273,6 +273,7 @@ class HUD_main(object): table_kwargs = dict(table_name = table_name, tournament = tour_number, table_number = tab_number) search_string = getTableTitleRe(self.config, site_name, type, **table_kwargs) + # print "getTableTitleRe ", self.config, site_name, type, "=", search_string tablewindow = Tables.Table(search_string, **table_kwargs) if tablewindow is None: diff --git a/pyfpdb/TableWindow.py b/pyfpdb/TableWindow.py index 10607b16..aa994bfe 100644 --- a/pyfpdb/TableWindow.py +++ b/pyfpdb/TableWindow.py @@ -11,12 +11,12 @@ of Table_Window objects representing the windows found. # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -58,7 +58,7 @@ bad_words = ('History for table:', 'HUD:', 'Chat:') # Here are the custom signals we define for allowing the 'client watcher' # thread to communicate with the gui thread. Any time a poker client is -# is moved, resized, or closed on of these signals is emitted to the +# is moved, resized, or closed on of these signals is emitted to the # HUD main window. gobject.signal_new("client_moved", gtk.Window, gobject.SIGNAL_RUN_LAST, @@ -80,16 +80,16 @@ gobject.signal_new("client_destroyed", gtk.Window, # from the corresponding hand history. # tw.site = the site name, e.g. PokerStars, FullTilt. This must match the site # name specified in the config file. -# tw.number = This is the system id number for the client table window in the +# tw.number = This is the system id number for the client table window in the # format that the system presents it. This is Xid in Xwindows and # hwnd in Microsoft Windows. # tw.title = The full title from the window title bar. -# tw.width, tw.height = The width and height of the window in pixels. This is -# the internal width and height, not including the title bar and +# tw.width, tw.height = The width and height of the window in pixels. This is +# the internal width and height, not including the title bar and # window borders. -# tw.x, tw.y = The x, y (horizontal, vertical) location of the window relative +# tw.x, tw.y = The x, y (horizontal, vertical) location of the window relative # to the top left of the display screen. This also does not include the -# title bar and window borders. To put it another way, this is the +# title bar and window borders. To put it another way, this is the # screen location of (0, 0) in the working window. class Table_Window(object): @@ -101,7 +101,7 @@ class Table_Window(object): self.table = int(table_number) self.name = "%s - %s" % (self.tournament, self.table) elif table_name is not None: - search_string = table_name + # search_string = table_name self.name = table_name self.tournament = None else: @@ -111,7 +111,7 @@ class Table_Window(object): def __str__(self): # __str__ method for testing - likely_attrs = ("site", "number", "title", "width", "height", "x", "y", + likely_attrs = ("site", "number", "title", "width", "height", "x", "y", "tournament", "table", "gdkhandle") temp = 'TableWindow object\n' for a in likely_attrs: @@ -125,7 +125,7 @@ class Table_Window(object): for game, names in game_names.iteritems(): for name in names: if name in title: - return game + return game return None def check_geometry(self): diff --git a/pyfpdb/WinTables.py b/pyfpdb/WinTables.py index 5bca9e41..255238f4 100644 --- a/pyfpdb/WinTables.py +++ b/pyfpdb/WinTables.py @@ -50,6 +50,7 @@ class Table(Table_Window): titles = {} win32gui.EnumWindows(win_enum_handler, titles) for hwnd in titles: + if titles[hwnd] == "": continue # print "searching ", search_string, " in ", titles[hwnd] if re.search(search_string, titles[hwnd]): if 'History for table:' in titles[hwnd]: continue # Everleaf Network HH viewer window