From c10665935fba50b1844cddda23f3dd7bde2beff4 Mon Sep 17 00:00:00 2001 From: Eric Blade Date: Thu, 4 Feb 2010 16:33:21 -0500 Subject: [PATCH 1/6] 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 From 4d45bd39d3b18c83b55637f38ee6ec6f8cbc6e83 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Thu, 4 Feb 2010 23:08:09 +0000 Subject: [PATCH 2/6] make enabled sites come first in drop-down (i.e. more chance of the default being the one you want) --- pyfpdb/GuiBulkImport.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py index 96842134..84828493 100755 --- a/pyfpdb/GuiBulkImport.py +++ b/pyfpdb/GuiBulkImport.py @@ -243,7 +243,17 @@ class GuiBulkImport(): # ComboBox - filter self.cbfilter = gtk.combo_box_new_text() + disabled_sites = [] # move disabled sites to bottom of list for w in self.config.hhcs: + try: + if self.config.supported_sites[w].enabled: # include enabled ones first + print w + self.cbfilter.append_text(w) + else: + disabled_sites.append(w) + except: # self.supported_sites[w] may not exist if hud_config is bad + disabled_sites.append(w) + for w in disabled_sites: # then disabled ones print w self.cbfilter.append_text(w) self.cbfilter.set_active(0) From ef2a8aca14f5c6862f17b725a2fdfec1a3dd69f9 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Thu, 4 Feb 2010 23:37:45 +0000 Subject: [PATCH 3/6] remove duplicate db calls which were slowing the hud down --- pyfpdb/HUD_main.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index bae58825..7e809332 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -245,10 +245,6 @@ class HUD_main(object): ,self.hero_ids[site_id], num_seats) t3 = time.time() try: - self.db_connection.init_hud_stat_vars( self.hud_dict[temp_key].hud_params['hud_days'] - , self.hud_dict[temp_key].hud_params['h_hud_days']) - t4 = time.time() - stat_dict = self.db_connection.get_stats_from_hand(new_hand_id, type, self.hud_dict[temp_key].hud_params, self.hero_ids[site_id]) self.hud_dict[temp_key].stat_dict = stat_dict except KeyError: # HUD instance has been killed off, key is stale sys.stderr.write('hud_dict[%s] was not found\n' % temp_key) @@ -256,9 +252,10 @@ class HUD_main(object): # Unlocks table, copied from end of function self.db_connection.connection.rollback() return - t5 = time.time() cards = self.db_connection.get_cards(new_hand_id) + t4 = time.time() comm_cards = self.db_connection.get_common_cards(new_hand_id) + t5 = time.time() if comm_cards != {}: # stud! cards['common'] = comm_cards['common'] self.hud_dict[temp_key].cards = cards From fde72003f7ec49021623c00f076cdbd3104e7cde Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 5 Feb 2010 11:44:27 +0800 Subject: [PATCH 4/6] test2.py - Add more tests Added most imports, and printed some formatted output for assiting diagnosis of new user installs --- pyfpdb/test2.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pyfpdb/test2.py b/pyfpdb/test2.py index 74ce1e72..8acdb089 100755 --- a/pyfpdb/test2.py +++ b/pyfpdb/test2.py @@ -22,12 +22,36 @@ Test if gtk is working. ######################################################################## import sys +import os try: + import gobject as _gobject + print "Import of gobject:\tSuccess" import pygtk + print "Import of pygtk:\tSuccess" pygtk.require('2.0') import gtk + print "Import of gtk:\t\tSuccess" + import pango + print "Import of pango:\tSuccess" + if os.name == 'nt': + import win32 + import win32api + print "Import of win32:\tSuccess" + + try: + import matplotlib + matplotlib.use('GTK') + print "Import of matplotlib:\tSuccess" + import numpy + print "Import of numpy:\tSuccess" + import pylab + print "Import of pylab:\tSuccess" + except: + print "\nError:", sys.exc_info() + print "\npress return to finish" + sys.stdin.readline() win = gtk.Window(gtk.WINDOW_TOPLEVEL) win.set_title("Test GTK") From ab693e3b3c0010b966a8d3ab9bb0fc5639ab16d3 Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 5 Feb 2010 11:51:12 +0800 Subject: [PATCH 5/6] test_PokerStars.py - Fix calls to HHC. sqlcoder added config as a parameter to HHC and Hand --- pyfpdb/test_PokerStars.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyfpdb/test_PokerStars.py b/pyfpdb/test_PokerStars.py index 4244f532..588368ab 100755 --- a/pyfpdb/test_PokerStars.py +++ b/pyfpdb/test_PokerStars.py @@ -27,9 +27,9 @@ settings.update(config.get_default_paths()) gametype = {'type':'ring', 'base':'draw', 'category':'badugi', 'limitType':'fl', 'sb':'0.25', 'bb':'0.50','currency':'USD'} text = "" -hhc = PokerStarsToFpdb.PokerStars(autostart=False) +hhc = PokerStarsToFpdb.PokerStars(config, autostart=False) -h = HoldemOmahaHand(None, "PokerStars", gametype, text, builtFrom = "Test") +h = HoldemOmahaHand(config, None, "PokerStars", gametype, text, builtFrom = "Test") h.addPlayer("1", "s0rrow", "100000") hhc.compilePlayerRegexs(h) @@ -39,7 +39,7 @@ def checkGameInfo(hhc, header, info): assert hhc.determineGameType(header) == info def testGameInfo(): - hhc = PokerStarsToFpdb.PokerStars(autostart=False) + hhc = PokerStarsToFpdb.PokerStars(config, autostart=False) pairs = ( (u"PokerStars Game #20461877044: Hold'em No Limit ($1/$2) - 2008/09/16 18:58:01 ET", {'type':'ring', 'base':"hold", 'category':'holdem', 'limitType':'nl', 'sb':'1', 'bb':'2', 'currency':'USD'}), From ac458386da2291de86eaee97cade229ecda45167 Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 5 Feb 2010 21:29:07 +0800 Subject: [PATCH 6/6] Add config path to test2.py display --- pyfpdb/test2.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyfpdb/test2.py b/pyfpdb/test2.py index 8acdb089..7dea96f6 100755 --- a/pyfpdb/test2.py +++ b/pyfpdb/test2.py @@ -23,6 +23,9 @@ Test if gtk is working. import sys import os +import Configuration + +config_path = Configuration.get_default_config_path() try: import gobject as _gobject @@ -66,7 +69,7 @@ try: (gtk.STOCK_CLOSE, gtk.RESPONSE_OK)) dia.set_default_size(500, 300) - l = gtk.Label("GTK is working!") + l = gtk.Label("GTK is working!\nConfig location: %s" %config_path) dia.vbox.add(l) l.show()