From 806744bf34eedf46ab0b80b4f23eca60ff59f88b Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 12 Nov 2008 23:02:51 -0500 Subject: [PATCH 1/5] Mucked window enabled. --- pyfpdb/Hud.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 39f30eea..42587189 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -194,9 +194,9 @@ class Hud: self.stats[config.supported_games[self.poker_game].stats[stat].row] \ [config.supported_games[self.poker_game].stats[stat].col] = \ config.supported_games[self.poker_game].stats[stat].stat_name -# self.mucked_window = gtk.Window() -# self.m = Mucked.Mucked(self.mucked_window, self.db_connection) -# self.mucked_window.show_all() + self.mucked_window = gtk.Window() + self.m = Mucked.Mucked(self.mucked_window, self.db_connection) + self.mucked_window.show_all() def update(self, hand, config, stat_dict): self.hand = hand # this is the last hand, so it is available later From d90fa208de767a6b945fa4f90d33426cb0750a93 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 13 Nov 2008 17:07:24 -0500 Subject: [PATCH 2/5] Smooth wrinkles in mucked card display. --- pyfpdb/Hud.py | 5 ++--- pyfpdb/Mucked.py | 35 ++++++++++++++++++++--------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 42587189..c2310c38 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -168,7 +168,6 @@ class Hud: adj = self.adj_seats(hand, config) loc = self.config.get_locations(self.table.site, self.max) - print "adj = ", adj # create the stat windows for i in range(1, self.max + 1): @@ -195,7 +194,7 @@ class Hud: [config.supported_games[self.poker_game].stats[stat].col] = \ config.supported_games[self.poker_game].stats[stat].stat_name self.mucked_window = gtk.Window() - self.m = Mucked.Mucked(self.mucked_window, self.db_connection) + self.m = Mucked.Mucked(self.mucked_window, self.config, self.db_name) self.mucked_window.show_all() def update(self, hand, config, stat_dict): @@ -217,7 +216,7 @@ class Hud: tip = stat_dict[s]['screen_name'] + "\n" + number[5] + "\n" + \ number[3] + ", " + number[4] Stats.do_tip(self.stat_windows[stat_dict[s]['seat']].e_box[r][c], tip) -# self.m.update(hand) + self.m.update(hand) def topify_window(self, window): """Set the specified gtk window to stayontop in MS Windows.""" diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index efb99e81..51681d2a 100644 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -45,26 +45,28 @@ import Mucked import HandHistory class Mucked: - def __init__(self, parent, db_connection): + def __init__(self, parent, config, db_name): - self.parent = parent #this is the parent of the mucked cards widget - self.db_connection = db_connection + self.config = config + self.parent = parent #this is the parent of the mucked cards widget + self.db_name = db_name self.vbox = gtk.VBox() self.parent.add(self.vbox) - self.mucked_list = MuckedList (self.vbox, db_connection) - self.mucked_cards = MuckedCards(self.vbox, db_connection) + self.mucked_list = MuckedList (self.vbox, config, db_name) + self.mucked_cards = MuckedCards(self.vbox, config, db_name) self.mucked_list.mucked_cards = self.mucked_cards def update(self, new_hand_id): self.mucked_list.update(new_hand_id) class MuckedList: - def __init__(self, parent, db_connection): + def __init__(self, parent, config, db_name): - self.parent = parent - self.db_connection = db_connection + self.parent = parent + self.config = config + self.db_name = db_name # set up a scrolled window to hold the listbox self.scrolled_window = gtk.ScrolledWindow() @@ -116,10 +118,11 @@ class MuckedList: self.mucked_cards.update(new_hand_id) class MuckedCards: - def __init__(self, parent, db_connection): + def __init__(self, parent, config, db_name = 'fpdb'): - self.parent = parent #this is the parent of the mucked cards widget - self.db_connection = db_connection + self.parent = parent #this is the parent of the mucked cards widget + self.config = config + self.db_name = db_name self.card_images = self.get_card_images() self.seen_cards = {} @@ -173,7 +176,8 @@ class MuckedCards: return old_cards def update(self, new_hand_id): - cards = self.db_connection.get_cards(new_hand_id) + db_connection = Database.Database(self.config, 'fpdb', '') + cards = db_connection.get_cards(new_hand_id) self.clear() cards = self.translate_cards(cards) for c in cards.keys(): @@ -185,7 +189,7 @@ class MuckedCards: set_from_pixbuf(self.card_images[self.split_cards(cards[c][i[1]])]) tips = [] - action = self.db_connection.get_action_from_hand(new_hand_id) + action = db_connection.get_action_from_hand(new_hand_id) for street in action: temp = '' for act in street: @@ -209,6 +213,7 @@ class MuckedCards: for round in range(1, len(tips)): for r in range(0, self.rows): self.eb[(round_to_col[round], r)].set_tooltip_text(tips[round]) + db_connection.close_connection() def split_cards(self, card): return (card[0], card[1].upper()) @@ -248,12 +253,12 @@ if __name__== "__main__": return(True) config = Configuration.Config() - db_connection = Database.Database(config, 'fpdb', '') +# db_connection = Database.Database(config, 'fpdb', '') main_window = gtk.Window() main_window.set_keep_above(True) main_window.connect("destroy", destroy) - m = Mucked(main_window, db_connection) + m = Mucked(main_window, config, 'fpdb') main_window.show_all() s_id = gobject.io_add_watch(sys.stdin, gobject.IO_IN, process_new_hand) From 37cd86920962b0d8fd05b55057050d9dce08863c Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 14 Nov 2008 13:10:17 -0500 Subject: [PATCH 3/5] fix reading of mucked cards for stud games --- pyfpdb/fpdb_simple.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index a746cf64..4c63657f 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -734,7 +734,7 @@ def parseCardLine(site, category, street, line, names, cardValues, cardSuits, bo print "line:",line,"cardValues[playerNo]:",cardValues[playerNo] raise FpdbError("read too many/too few holecards in parseCardLine") elif (category=="razz" or category=="studhi" or category=="studhilo"): - if (line.find("shows")==-1): + if (line.find("shows")==-1 and line.find("mucked") == -1): #print "parseCardLine(in stud if), street:", street if line[pos+2]=="]": #-> not (hero and 3rd street) cardValues[playerNo][street+2]=line[pos:pos+1] From 17ad79691737b3bec44805f43e5b9dbba1fd5f22 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 16 Nov 2008 17:53:31 -0500 Subject: [PATCH 4/5] More changes to support mucked/aux windows. --- pyfpdb/Configuration.py | 86 ++++++++++++++++++++++++++++++-------- pyfpdb/HUD_main.py | 5 +++ pyfpdb/Hud.py | 13 ++++-- pyfpdb/Mucked.py | 91 ++++++++++++++++++++++++++++++++++++----- 4 files changed, 163 insertions(+), 32 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 99582935..dcd64c57 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -58,6 +58,7 @@ class Site: self.hudfgcolor = node.getAttribute("fgcolor") self.converter = node.getAttribute("converter") self.enabled = node.getAttribute("enabled") + self.aux_window = node.getAttribute("aux_window") self.layout = {} for layout_node in node.getElementsByTagName('layout'): @@ -100,6 +101,7 @@ class Game: self.db = node.getAttribute("db") self.rows = int( node.getAttribute("rows") ) self.cols = int( node.getAttribute("cols") ) + self.aux = node.getAttribute("aux") self.stats = {} for stat_node in node.getElementsByTagName('stat'): @@ -120,6 +122,7 @@ class Game: temp = temp + " db = %s\n" % self.db temp = temp + " rows = %d\n" % self.rows temp = temp + " cols = %d\n" % self.cols + temp = temp + " aux = %s\n" % self.aux for stat in self.stats.keys(): temp = temp + "%s" % self.stats[stat] @@ -144,18 +147,20 @@ class Database: temp = temp + ' ' + key + " = " + value + "\n" return temp -class Mucked: +class Aux_window: def __init__(self, node): - self.name = node.getAttribute("mw_name") - self.cards = node.getAttribute("deck") - self.card_wd = node.getAttribute("card_wd") - self.card_ht = node.getAttribute("card_ht") - self.rows = node.getAttribute("rows") - self.cols = node.getAttribute("cols") - self.format = node.getAttribute("stud") + for (name, value) in node.attributes.items(): + setattr(self, name, value) +# self.name = node.getAttribute("mw_name") +# self.cards = node.getAttribute("deck") +# self.card_wd = node.getAttribute("card_wd") +# self.card_ht = node.getAttribute("card_ht") +# self.rows = node.getAttribute("rows") +# self.cols = node.getAttribute("cols") +# self.format = node.getAttribute("stud") def __str__(self): - temp = 'Mucked = ' + self.name + "\n" + temp = 'Aux = ' + self.name + "\n" for key in dir(self): if key.startswith('__'): continue value = getattr(self, key) @@ -238,7 +243,7 @@ class Config: self.supported_sites = {} self.supported_games = {} self.supported_databases = {} - self.mucked_windows = {} + self.aux_windows = {} self.popup_windows = {} # s_sites = doc.getElementsByTagName("supported_sites") @@ -257,9 +262,9 @@ class Config: self.supported_databases[db.db_name] = db # s_dbs = doc.getElementsByTagName("mucked_windows") - for mw_node in doc.getElementsByTagName("mw"): - mw = Mucked(node = mw_node) - self.mucked_windows[mw.name] = mw + for aw_node in doc.getElementsByTagName("aw"): + aw = Aux_window(node = aw_node) + self.aux_windows[aw.name] = aw # s_dbs = doc.getElementsByTagName("popup_windows") for pu_node in doc.getElementsByTagName("pu"): @@ -503,6 +508,7 @@ class Config: parms["HH_path"] = self.supported_sites[site].HH_path parms["site_name"] = self.supported_sites[site].site_name parms["enabled"] = self.supported_sites[site].enabled + parms["aux_window"] = self.supported_sites[site].aux_window return parms def set_site_parameters(self, site_name, converter = None, decoder = None, @@ -537,6 +543,44 @@ class Config: if not enabled == None: self.supported_sites[site].enabled = enabled return + def get_aux_windows(self): + """Gets the list of mucked window formats in the configuration.""" + mw = [] + for w in self.aux_windows.keys(): + mw.append(w) + return mw + + def get_aux_parameters(self, name): + """Gets a dict of mucked window parameters from the named mw.""" + param = {} + if self.aux_windows.has_key(name): + for key in dir(self.aux_windows[name]): + if key.startswith('__'): continue + value = getattr(self.aux_windows[name], key) + if callable(value): continue + param[key] = value + + return param + return None + + def get_game_parameters(self, name): + """Get the configuration parameters for the named game.""" + param = {} + if self.supported_games.has_key(name): + param['game_name'] = self.supported_games[name].game_name + param['db'] = self.supported_games[name].db + param['rows'] = self.supported_games[name].rows + param['cols'] = self.supported_games[name].cols + param['aux'] = self.supported_games[name].aux + return param + + def get_supported_games(self): + """Get the list of supported games.""" + sg = [] + for game in c.supported_games.keys(): + sg.append(c.supported_games[game].game_name) + return sg + if __name__== "__main__": c = Config() @@ -557,15 +601,15 @@ if __name__== "__main__": print c.supported_databases[db] print "----------- END SUPPORTED DATABASES -----------" - print "\n----------- MUCKED WINDOW FORMATS -----------" - for w in c.mucked_windows.keys(): - print c.mucked_windows[w] - print "----------- END MUCKED WINDOW FORMATS -----------" + print "\n----------- AUX WINDOW FORMATS -----------" + for w in c.aux_windows.keys(): + print c.aux_windows[w] + print "----------- END AUX WINDOW FORMATS -----------" print "\n----------- POPUP WINDOW FORMATS -----------" for w in c.popup_windows.keys(): print c.popup_windows[w] - print "----------- END MUCKED WINDOW FORMATS -----------" + print "----------- END POPUP WINDOW FORMATS -----------" print "\n----------- IMPORT -----------" tmp = c.get_import_parameters() @@ -586,6 +630,12 @@ if __name__== "__main__": print "paths = ", c.get_default_paths("PokerStars") print "colors = ", c.get_default_colors("PokerStars") print "locs = ", c.get_locations("PokerStars", 8) + for mw in c.get_aux_windows(): + print c.get_aux_parameters(mw) + for site in c.supported_sites.keys(): print "site = ", site, print c.get_site_parameters(site) + + for game in c.get_supported_games(): + print c.get_game_parameters(game) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index 1a7e058e..ffa307d0 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -83,6 +83,8 @@ def update_HUD(new_hand_id, table_name, config, stat_dict): gtk.gdk.threads_enter() try: hud_dict[table_name].update(new_hand_id, config, stat_dict) + for m in hud_dict[table_name].aux_windows: + m.update_gui(new_hand_id) return False finally: gtk.gdk.threads_leave() @@ -121,6 +123,9 @@ def read_stdin(): # This is the thread function # if a hud for this CASH table exists, just update it if hud_dict.has_key(table_name): +# update the data for the aux_windows + for aw in hud_dict[table_name].aux_windows: + aw.update_data(new_hand_id) update_HUD(new_hand_id, table_name, config, stat_dict) # if a hud for this TOURNAMENT table exists, just update it elif hud_dict.has_key(tour_number): diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index c2310c38..d9816ef1 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -59,6 +59,7 @@ class Hud: self.stat_windows = {} self.popup_windows = {} + self.aux_windows = [] self.font = pango.FontDescription("Sans 8") # Set up a main window for this this instance of the HUD @@ -193,9 +194,11 @@ class Hud: self.stats[config.supported_games[self.poker_game].stats[stat].row] \ [config.supported_games[self.poker_game].stats[stat].col] = \ config.supported_games[self.poker_game].stats[stat].stat_name - self.mucked_window = gtk.Window() - self.m = Mucked.Mucked(self.mucked_window, self.config, self.db_name) - self.mucked_window.show_all() + + game_params = config.get_game_parameters(self.poker_game) + if not game_params['aux'] == "": + aux_params = config.get_aux_parameters(game_params['aux']) + self.aux_windows.append(eval("%s.%s(gtk.Window(), config, 'fpdb')" % (aux_params['module'], aux_params['class']))) def update(self, hand, config, stat_dict): self.hand = hand # this is the last hand, so it is available later @@ -216,7 +219,9 @@ class Hud: tip = stat_dict[s]['screen_name'] + "\n" + number[5] + "\n" + \ number[3] + ", " + number[4] Stats.do_tip(self.stat_windows[stat_dict[s]['seat']].e_box[r][c], tip) - self.m.update(hand) +# for m in self.aux_windows: +# m.update_data(hand) +# m.update_gui(hand) def topify_window(self, window): """Set the specified gtk window to stayontop in MS Windows.""" diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index 51681d2a..6f1fadd0 100644 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -41,10 +41,21 @@ import Configuration import Database import Tables import Hud -import Mucked import HandHistory -class Mucked: +class Aux_Window: + def __init__(self, parent, config, db_name): + self.config = config + self.parent = parent #this is the parent of the mucked cards widget + self.db_name = db_name + + self.vbox = gtk.VBox() + self.parent.add(self.vbox) + + def update(self): + pass + +class Stud_mucked(Aux_Window): def __init__(self, parent, config, db_name): self.config = config @@ -54,14 +65,18 @@ class Mucked: self.vbox = gtk.VBox() self.parent.add(self.vbox) - self.mucked_list = MuckedList (self.vbox, config, db_name) - self.mucked_cards = MuckedCards(self.vbox, config, db_name) + self.mucked_list = Stud_list(self.vbox, config, db_name) + self.mucked_cards = Stud_cards(self.vbox, config, db_name) self.mucked_list.mucked_cards = self.mucked_cards + self.parent.show_all() - def update(self, new_hand_id): - self.mucked_list.update(new_hand_id) + def update_data(self, new_hand_id): + self.mucked_list.update_data(new_hand_id) -class MuckedList: + def update_gui(self, new_hand_id): + self.mucked_list.update_gui(new_hand_id) + +class Stud_list: def __init__(self, parent, config, db_name): self.parent = parent @@ -116,8 +131,21 @@ class MuckedList: vadj = self.scrolled_window.get_vadjustment() vadj.set_value(vadj.upper) self.mucked_cards.update(new_hand_id) + + def update_data(self, new_hand_id): + self.info_row = ((new_hand_id, "xxxx", 0), ) + self.mucked_cards.update_data(new_hand_id) -class MuckedCards: + def update_gui(self, new_hand_id): + iter = self.liststore.append(self.info_row[0]) + sel = self.treeview.get_selection() + sel.select_iter(iter) + + vadj = self.scrolled_window.get_vadjustment() + vadj.set_value(vadj.upper) + self.mucked_cards.update_gui(new_hand_id) + +class Stud_cards: def __init__(self, parent, config, db_name = 'fpdb'): self.parent = parent #this is the parent of the mucked cards widget @@ -215,6 +243,47 @@ class MuckedCards: self.eb[(round_to_col[round], r)].set_tooltip_text(tips[round]) db_connection.close_connection() + def update_data(self, new_hand_id): + db_connection = Database.Database(self.config, 'fpdb', '') + cards = db_connection.get_cards(new_hand_id) + self.clear() + self.cards = self.translate_cards(cards) + + self.tips = [] + action = db_connection.get_action_from_hand(new_hand_id) + for street in action: + temp = '' + for act in street: + temp = temp + act[0] + " " + act[1] + "s " + if act[2] > 0: + if act[2]%100 > 0: + temp = temp + "%4.2f\n" % (float(act[2])/100) + else: + temp = temp + "%d\n" % (act[2]/100) + else: + temp = temp + "\n" + self.tips.append(temp) + db_connection.close_connection() + + def update_gui(self, new_hand_id): + for c in self.cards.keys(): + self.grid_contents[(1, self.cards[c]['seat_number'] - 1)].set_text(self.cards[c]['screen_name']) + for i in ((0, 'hole_card_1'), (1, 'hole_card_2'), (2, 'hole_card_3'), (3, 'hole_card_4'), + (4, 'hole_card_5'), (5, 'hole_card_6'), (6, 'hole_card_7')): + if not self.cards[c][i[1]] == "xx": + self.seen_cards[(i[0], self.cards[c]['seat_number'] - 1)]. \ + set_from_pixbuf(self.card_images[self.split_cards(self.cards[c][i[1]])]) +## action in tool tips for 3rd street cards + for c in (0, 1, 2): + for r in range(0, self.rows): + self.eb[(c, r)].set_tooltip_text(self.tips[0]) + +# action in tools tips for later streets + round_to_col = (0, 3, 4, 5, 6) + for round in range(1, len(self.tips)): + for r in range(0, self.rows): + self.eb[(round_to_col[round], r)].set_tooltip_text(self.tips[round]) + def split_cards(self, card): return (card[0], card[1].upper()) @@ -249,7 +318,8 @@ if __name__== "__main__": # just read it and pass it to update new_hand_id = sys.stdin.readline() new_hand_id = new_hand_id.rstrip() # remove trailing whitespace - m.update(new_hand_id) + m.update_data(new_hand_id) + m.update_gui(new_hand_id) return(True) config = Configuration.Config() @@ -258,7 +328,8 @@ if __name__== "__main__": main_window.set_keep_above(True) main_window.connect("destroy", destroy) - m = Mucked(main_window, config, 'fpdb') + aux_to_call = "Stud_mucked" + m = eval("%s(main_window, config, 'fpdb')" % aux_to_call) main_window.show_all() s_id = gobject.io_add_watch(sys.stdin, gobject.IO_IN, process_new_hand) From 2155c125870ec558371e3ff843465c11592dd511 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 22 Nov 2008 17:28:12 -0500 Subject: [PATCH 5/5] Fixed error detecting FTP tables on NT --- pyfpdb/Tables.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Tables.py b/pyfpdb/Tables.py index 2b312f40..9f5360e2 100755 --- a/pyfpdb/Tables.py +++ b/pyfpdb/Tables.py @@ -229,6 +229,7 @@ def discover_nt_by_name(c, tablename): if titles[hwnd].find(tablename) == -1: continue if titles[hwnd].find("History for table:") > -1: continue if titles[hwnd].find("HUD:") > -1: continue + if titles[hwnd].find("Chat:") > -1: continue return decode_windows(c, titles[hwnd], hwnd) return False @@ -428,7 +429,7 @@ def discover_mac_by_name(c, tablename): if __name__=="__main__": c = Configuration.Config() - print discover_table_by_name(c, "Ostara V") + print discover_table_by_name(c, "Howard Lederer") print discover_tournament_table(c, "118942908", "3") tables = discover(c)