From 99e4211e5d669cee4f0ccfe3d1c82e80fe30414e Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Fri, 6 Nov 2009 17:34:42 -0500 Subject: [PATCH] Integrate new table handling code. --- pyfpdb/HUD_main.py | 16 ++++++++++++---- pyfpdb/SQL.py | 10 +++++----- pyfpdb/TableWindow.py | 10 +++++----- pyfpdb/Tables_Demo.py | 0 pyfpdb/XTables.py | 3 ++- 5 files changed, 24 insertions(+), 15 deletions(-) mode change 100644 => 100755 pyfpdb/Tables_Demo.py diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index 0fce160f..e9fb40fb 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -53,7 +53,12 @@ import gobject # FreePokerTools modules import Configuration import Database -import Tables +# get the correct module for the current os +if os.name == 'posix': + import XTables as Tables +elif os.name == 'nt': + import WinTables as Tables +#import Tables import Hud @@ -131,6 +136,7 @@ class HUD_main(object): # TODO: The purpose of this try/finally block is to make darn sure that threads_leave() # TODO: gets called. If there is an exception and threads_leave() doesn't get called we # TODO: lock up. REB + table.gdkhandle = gtk.gdk.window_foreign_new(table.number) newlabel = gtk.Label("%s - %s" % (table.site, table_name)) self.vb.add(newlabel) newlabel.show() @@ -210,7 +216,7 @@ class HUD_main(object): # get basic info about the new hand from the db # if there is a db error, complain, skip hand, and proceed try: - (table_name, max, poker_game, type, site_id, tour_number, tab_number) = \ + (table_name, max, poker_game, type, site_id, site_name, tour_number, tab_number) = \ self.db_connection.get_table_info(new_hand_id) except Exception, err: print "db error: skipping %s" % new_hand_id @@ -248,15 +254,17 @@ class HUD_main(object): cards['common'] = comm_cards['common'] if type == "tour": - tablewindow = Tables.discover_tournament_table(self.config, tour_number, tab_number) + tablewindow = Tables.Table(tournament = tour_number, table_number = tab_number) else: - tablewindow = Tables.discover_table_by_name(self.config, table_name) + tablewindow = Tables.Table(table_name = table_name) if tablewindow is None: # If no client window is found on the screen, complain and continue if type == "tour": table_name = "%s %s" % (tour_number, tab_number) sys.stderr.write("HUD create: table name "+table_name+" not found, skipping.\n") else: + tablewindow.max = max + tablewindow.site = site_name self.create_HUD(new_hand_id, tablewindow, temp_key, max, poker_game, type, stat_dict, cards) self.db_connection.connection.rollback() diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 05edb56a..e8e93ed3 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -1605,11 +1605,11 @@ class Sql: """ self.query['get_table_name'] = """ - select h.tableName, h.maxSeats, gt.category, gt.type, gt.siteId - from Hands h - ,Gametypes gt - where h.id = %s - and gt.id = h.gametypeId + SELECT h.tableName, h.maxSeats, gt.category, gt.type, s.id, s.name + FROM Hands h, Gametypes gt, Sites s + WHERE h.id = %s + AND gt.id = h.gametypeId + AND s.id = gt.siteID """ self.query['get_actual_seat'] = """ diff --git a/pyfpdb/TableWindow.py b/pyfpdb/TableWindow.py index 0fa2bf22..bdc9db87 100644 --- a/pyfpdb/TableWindow.py +++ b/pyfpdb/TableWindow.py @@ -113,12 +113,12 @@ class Table_Window(object): def __str__(self): # __str__ method for testing + likely_attrs = ("site", "number", "title", "width", "height", "x", "y", + "tournament", "table", "gdkhandle") temp = 'TableWindow object\n' - temp = temp + " name = %s\n site = %s\n number = %s\n title = %s\n" % (self.name, self.site, self.number, self.title) -# temp = temp + " game = %s\n structure = %s\n max = %s\n" % (self.game, self.structure, self.max) - temp = temp + " width = %d\n height = %d\n x = %d\n y = %d\n" % (self.width, self.height, self.x, self.y) - if getattr(self, 'tournament', 0): - temp = temp + " tournament = %d\n table = %d" % (self.tournament, self.table) + for a in likely_attrs: + if getattr(self, a, 0): + temp += " %s = %s\n" % (a, getattr(self, a)) return temp def get_game(self): diff --git a/pyfpdb/Tables_Demo.py b/pyfpdb/Tables_Demo.py old mode 100644 new mode 100755 diff --git a/pyfpdb/XTables.py b/pyfpdb/XTables.py index 1e692209..fd1ce9c1 100644 --- a/pyfpdb/XTables.py +++ b/pyfpdb/XTables.py @@ -79,7 +79,8 @@ class Table(Table_Window): self.gdk_handle = None else: self.number = int( mo.group(1), 0) - self.gdk_handle = gtk.gdk.window_foreign_new(int(self.number)) + print "number =", self.number +# self.gdk_handle = gtk.gdk.window_foreign_new(int(self.number)) def get_geometry(self): try: