From 969f5cc265e9ee4d7f1609c35f4f2423d541b94a Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 21 Mar 2009 12:54:51 -0400 Subject: [PATCH 01/23] Make shift-middle-click work as intended. --- pyfpdb/Mucked.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index fe2baa71..6bc6a58a 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -54,7 +54,10 @@ class Aux_Window: pass def destroy(self): - self.container.destroy() + try: + self.container.destroy() + except: + pass ############################################################################ # Some utility routines useful for Aux_Windows @@ -413,6 +416,7 @@ class Flop_Mucked(Aux_Window): if event.state & gtk.gdk.SHIFT_MASK: self.timer_on = False self.expose_all() + return if event.button == 3: # right button event pass From 8ebcd7b68a4f5b37ea1d7e593526e6d015330f5f Mon Sep 17 00:00:00 2001 From: Worros Date: Sun, 22 Mar 2009 02:17:48 +0900 Subject: [PATCH 02/23] Fix crash on Stars tourney import If importing a tourney and the line was marked as crap this test crashed the importer --- 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 fc6c13b2..b0263888 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -714,7 +714,7 @@ def filterCrap(site, hand, isTourney): hand[i] = False elif (hand[i].find(": ")!=-1 and site=="ftp" and hand[i].find("Seat ")==-1 and hand[i].find(": Table")==-1): #filter ftp chat hand[i] = False - if isTourney: + if isTourney and not hand[i] == False: if (hand[i].endswith(" is sitting out") and (not hand[i].startswith("Seat "))): hand[i] = False elif hand[i]: From 38b0fc71577182fcc8e0333e9f9ae175a9be020c Mon Sep 17 00:00:00 2001 From: Worros Date: Sun, 22 Mar 2009 02:20:56 +0900 Subject: [PATCH 03/23] Add all functional site importers to Bulk import gui --- pyfpdb/GuiBulkImport.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py index 6745e9fc..84ef4645 100755 --- a/pyfpdb/GuiBulkImport.py +++ b/pyfpdb/GuiBulkImport.py @@ -176,7 +176,10 @@ class GuiBulkImport(): # ComboBox - filter self.cbfilter = gtk.combo_box_new_text() self.cbfilter.append_text("passthrough") - self.cbfilter.append_text("Everleaf") + self.cbfilter.append_text("BetfairToFpdb") + self.cbfilter.append_text("EverleafToFpdb") + self.cbfilter.append_text("FulltiltToFpdb") + self.cbfilter.append_text("PokerStarsToFpdb") self.cbfilter.set_active(0) self.table.attach(self.cbfilter, 3, 4, 2, 3, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK) self.cbfilter.show() From 50f775e7935549c38e89951e01ea44600f89a42f Mon Sep 17 00:00:00 2001 From: Matt Turnbull Date: Sat, 21 Mar 2009 17:46:16 +0000 Subject: [PATCH 04/23] More sensible prints when dropping psql indexes --- pyfpdb/fpdb_simple.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 2677d11b..51df87a1 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -157,12 +157,13 @@ def prepareBulkImport(fdb): pass elif fdb.backend == PGSQL: # DON'T FORGET TO RECREATE THEM!! - print "dropping pg fk", fk['fktab'], fk['fkcol'] + #print "dropping pg fk", fk['fktab'], fk['fkcol'] try: fdb.cursor.execute("alter table " + fk['fktab'] + " drop constraint " + fk['fktab'] + '_' + fk['fkcol'] + '_fkey') + print "dropped pg fk pg fk %s_%s_fkey" % (fk['fktab'], fk['fkcol']) except: - pass + print "! failed drop pg fk %s_%s_fkey" % (fk['fktab'], fk['fkcol']) else: print "Only MySQL and Postgres supported so far" return -1 @@ -177,15 +178,15 @@ def prepareBulkImport(fdb): pass elif fdb.backend == PGSQL: # DON'T FORGET TO RECREATE THEM!! - print "Index dropping disabled for postgresql." - print "dropping pg index ", idx['tab'], idx['col'] + #print "Index dropping disabled for postgresql." + #print "dropping pg index ", idx['tab'], idx['col'] # mod to use tab_col for index name? try: - print "drop index %s_%s_idx" % (idx['tab'],idx['col']) fdb.cursor.execute( "drop index %s_%s_idx" % (idx['tab'],idx['col']) ) - print "dropped pg index ", idx['tab'], idx['col'] + print "drop index %s_%s_idx" % (idx['tab'],idx['col']) + #print "dropped pg index ", idx['tab'], idx['col'] except: - pass + print "! failed drop index %s_%s_idx" % (idx['tab'],idx['col']) else: print "Only MySQL and Postgres supported so far" return -1 From 2747b079eddfe65ae46826b41466e2678fc1eab8 Mon Sep 17 00:00:00 2001 From: Worros Date: Sun, 22 Mar 2009 02:52:41 +0900 Subject: [PATCH 05/23] Fix saveActions to True by default --- pyfpdb/fpdb_save_to_db.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py index dc2418cf..7a5c7d6d 100644 --- a/pyfpdb/fpdb_save_to_db.py +++ b/pyfpdb/fpdb_save_to_db.py @@ -28,7 +28,7 @@ SQLITE = 4 fastStoreHudCache = True # set this to True to test the new storeHudCache routine -saveActions = False # set this to False to avoid storing action data +saveActions = True # set this to False to avoid storing action data # Pros: speeds up imports # Cons: no action data is saved, so you need to keep the hand histories # variance not available on stats page @@ -70,8 +70,10 @@ def ring_holdem_omaha(config, backend, db, cursor, base, category, site_hand_no, """stores a holdem/omaha hand into the database""" import_options = config.get_import_parameters() - saveActions = True if import_options['saveActions'] == 'True' else False - fastStoreHudCache = True if import_options['fastStoreHudCache'] == 'True' else False + saveActions = False if import_options['saveActions'] == 'False' else True + fastStoreHudCache = False if import_options['fastStoreHudCache'] == 'False' else True + + print "DEBUG: saveActions = '%s' fastStoreHudCache = '%s'"%(saveActions, fastStoreHudCache) t0 = time() fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) From 999a2b9b5fcd3221f947f153e83ddb269726a0f0 Mon Sep 17 00:00:00 2001 From: Worros Date: Sun, 22 Mar 2009 02:57:37 +0900 Subject: [PATCH 06/23] Remove debug statement --- pyfpdb/fpdb_save_to_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py index 7a5c7d6d..01bd71cc 100644 --- a/pyfpdb/fpdb_save_to_db.py +++ b/pyfpdb/fpdb_save_to_db.py @@ -73,7 +73,7 @@ def ring_holdem_omaha(config, backend, db, cursor, base, category, site_hand_no, saveActions = False if import_options['saveActions'] == 'False' else True fastStoreHudCache = False if import_options['fastStoreHudCache'] == 'False' else True - print "DEBUG: saveActions = '%s' fastStoreHudCache = '%s'"%(saveActions, fastStoreHudCache) + # print "DEBUG: saveActions = '%s' fastStoreHudCache = '%s'"%(saveActions, fastStoreHudCache) t0 = time() fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) From 208176077e847d555a3ad70a80a17b072d2f2ee9 Mon Sep 17 00:00:00 2001 From: Worros Date: Sun, 22 Mar 2009 02:59:47 +0900 Subject: [PATCH 07/23] Add test code for executemany function --- pyfpdb/fpdb_simple.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index b0263888..7f241a2c 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -29,6 +29,8 @@ MYSQL_INNODB = 2 PGSQL = 3 SQLITE = 4 +DBTEST = False + # Data Structures for index and foreign key creation # drop_code is an int with possible values: 0 - don't drop for bulk import # 1 - drop during bulk import @@ -1511,11 +1513,18 @@ def storeActions(cursor, handsPlayersIds, actionTypes, allIns, actionAmounts, ac #stores into table hands_actions #print "start of storeActions, actionNos:",actionNos #print " action_amounts:",action_amounts + inserts = [] for i in xrange(len(actionTypes)): #iterate through streets for j in xrange(len(actionTypes[i])): #iterate through names for k in xrange(len(actionTypes[i][j])): #iterate through individual actions of that player on that street - cursor.execute ("INSERT INTO HandsActions (handPlayerId, street, actionNo, action, allIn, amount) VALUES (%s, %s, %s, %s, %s, %s)" - , (handsPlayersIds[j], i, actionNos[i][j][k], actionTypes[i][j][k], allIns[i][j][k], actionAmounts[i][j][k])) + if DBTEST == False: + cursor.execute("INSERT INTO HandsActions (handPlayerId, street, actionNo, action, allIn, amount) VALUES (%s, %s, %s, %s, %s, %s)", (handsPlayersIds[j], i, actionNos[i][j][k], actionTypes[i][j][k], allIns[i][j][k], actionAmounts[i][j][k])) + else: + # Add inserts into a list and let + inserts = inserts + [(handsPlayersIds[j], i, actionNos[i][j][k], actionTypes[i][j][k], allIns[i][j][k], actionAmounts[i][j][k])] + + if DBTEST == True: + cursor.executemany("INSERT INTO HandsActions (handPlayerId, street, actionNo, action, allIn, amount) VALUES (%s, %s, %s, %s, %s, %s)", inserts) #end def storeActions def store_board_cards(cursor, hands_id, board_values, board_suits): From e9853c1ff23b88514bb5126928697b0e12c7674d Mon Sep 17 00:00:00 2001 From: Worros Date: Sun, 22 Mar 2009 04:07:08 +0900 Subject: [PATCH 08/23] Make previous executemany() function the default --- pyfpdb/fpdb_simple.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 7f241a2c..aa876804 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -29,7 +29,6 @@ MYSQL_INNODB = 2 PGSQL = 3 SQLITE = 4 -DBTEST = False # Data Structures for index and foreign key creation # drop_code is an int with possible values: 0 - don't drop for bulk import @@ -1517,14 +1516,10 @@ def storeActions(cursor, handsPlayersIds, actionTypes, allIns, actionAmounts, ac for i in xrange(len(actionTypes)): #iterate through streets for j in xrange(len(actionTypes[i])): #iterate through names for k in xrange(len(actionTypes[i][j])): #iterate through individual actions of that player on that street - if DBTEST == False: - cursor.execute("INSERT INTO HandsActions (handPlayerId, street, actionNo, action, allIn, amount) VALUES (%s, %s, %s, %s, %s, %s)", (handsPlayersIds[j], i, actionNos[i][j][k], actionTypes[i][j][k], allIns[i][j][k], actionAmounts[i][j][k])) - else: - # Add inserts into a list and let - inserts = inserts + [(handsPlayersIds[j], i, actionNos[i][j][k], actionTypes[i][j][k], allIns[i][j][k], actionAmounts[i][j][k])] + # Add inserts into a list and let + inserts = inserts + [(handsPlayersIds[j], i, actionNos[i][j][k], actionTypes[i][j][k], allIns[i][j][k], actionAmounts[i][j][k])] - if DBTEST == True: - cursor.executemany("INSERT INTO HandsActions (handPlayerId, street, actionNo, action, allIn, amount) VALUES (%s, %s, %s, %s, %s, %s)", inserts) + cursor.executemany("INSERT INTO HandsActions (handPlayerId, street, actionNo, action, allIn, amount) VALUES (%s, %s, %s, %s, %s, %s)", inserts) #end def storeActions def store_board_cards(cursor, hands_id, board_values, board_suits): From 3f879ddb3d56122d08c4314ed0e280b6fe225827 Mon Sep 17 00:00:00 2001 From: Matt Turnbull Date: Sat, 21 Mar 2009 21:38:32 +0000 Subject: [PATCH 09/23] psql drop fk hang: seemed to be caused by having more than one connection to the db open. Made GuiBulkImport use the importer's connection instead of its own. It still has the one given to it by fpdb.py. I really don't know. Perhaps it needed a commit. --- pyfpdb/GuiBulkImport.py | 8 ++++---- pyfpdb/fpdb_import.py | 1 - pyfpdb/fpdb_simple.py | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py index 84ef4645..2b1fe500 100755 --- a/pyfpdb/GuiBulkImport.py +++ b/pyfpdb/GuiBulkImport.py @@ -197,8 +197,8 @@ class GuiBulkImport(): self.load_button.show() # see how many hands are in the db and adjust accordingly - tcursor = db.db.cursor() - tcursor.execute("Select count(1) from Hands;") + tcursor = self.importer.fdb.db.cursor() + tcursor.execute("Select count(1) from Hands") row = tcursor.fetchone() tcursor.close() self.n_hands_in_db = row[0] @@ -233,8 +233,8 @@ def main(argv=None): (options, sys.argv) = parser.parse_args(args = argv) config = Configuration.Config() - db = fpdb_db.fpdb_db() - + db = None + settings = {} settings['minPrint'] = options.minPrint if os.name == 'nt': settings['os'] = 'windows' diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 5d04a1f9..2c33a841 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -178,7 +178,6 @@ class Importer: tmpcursor = self.fdb.db.cursor() tmpcursor.execute("Select count(1) from Hands;") self.settings['handsInDB'] = tmpcursor.fetchone()[0] - tmpcursor.close() except: pass # if this fails we're probably doomed anyway if self.settings['handsInDB'] < 5000: return "drop" diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index e39fabd5..aaf2d1d2 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -53,7 +53,7 @@ indexes = [ , [ # indexes for postgres (list index 3) {'tab':'Boardcards', 'col':'handId', 'drop':0} , {'tab':'Gametypes', 'col':'siteId', 'drop':0} - , {'tab':'Hands', 'col':'gametypeId', 'drop':1} + , {'tab':'Hands', 'col':'gametypeId', 'drop':1} # todo :1 by sqlcoder , but this is needed for all duplicate checks. test 0 , {'tab':'Hands', 'col':'siteHandNo', 'drop':0} , {'tab':'HandsActions', 'col':'handplayerId', 'drop':0} , {'tab':'HandsPlayers', 'col':'handId', 'drop':1} @@ -164,8 +164,8 @@ def prepareBulkImport(fdb): # DON'T FORGET TO RECREATE THEM!! #print "dropping pg fk", fk['fktab'], fk['fkcol'] try: - fdb.cursor.execute("alter table " + fk['fktab'] + " drop constraint " - + fk['fktab'] + '_' + fk['fkcol'] + '_fkey') + #print "alter table %s drop constraint %s_%s_fkey" % (fk['fktab'], fk['fktab'], fk['fkcol']) + fdb.cursor.execute("alter table %s drop constraint %s_%s_fkey" % (fk['fktab'], fk['fktab'], fk['fkcol'])) print "dropped pg fk pg fk %s_%s_fkey" % (fk['fktab'], fk['fkcol']) except: print "! failed drop pg fk %s_%s_fkey" % (fk['fktab'], fk['fkcol']) From 40c17cffaa082396735cd1b930fa6aa23bf3f2df Mon Sep 17 00:00:00 2001 From: Worros Date: Sun, 22 Mar 2009 18:52:30 +0900 Subject: [PATCH 10/23] Recognise deep 6 tables at Full Tilt --- pyfpdb/FulltiltToFpdb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyfpdb/FulltiltToFpdb.py b/pyfpdb/FulltiltToFpdb.py index b5f0cc4e..6a897bad 100755 --- a/pyfpdb/FulltiltToFpdb.py +++ b/pyfpdb/FulltiltToFpdb.py @@ -124,8 +124,8 @@ follow : whether to tail -f the input""" hand.starttime = time.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d") hand.maxseats = 8 # assume 8-max until we see otherwise if m.group('TABLEATTRIBUTES'): - m2 = re.search("(\d+) max", m.group('TABLEATTRIBUTES')) - hand.maxseats = int(m2.group(1)) + m2 = re.search("(deep )?(\d+)( max)?", m.group('TABLEATTRIBUTES')) + hand.maxseats = int(m2.group(2)) # These work, but the info is already in the Hand class - should be used for tourneys though. # m.group('SB') # m.group('BB') From 6e021ea3a4ff8d4f41fca9845dd02f9dfef2e2d1 Mon Sep 17 00:00:00 2001 From: Worros Date: Sun, 22 Mar 2009 18:56:51 +0900 Subject: [PATCH 11/23] Remove old graph queries from file --- pyfpdb/FpdbSQLQueries.py | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/pyfpdb/FpdbSQLQueries.py b/pyfpdb/FpdbSQLQueries.py index c3260466..24948986 100644 --- a/pyfpdb/FpdbSQLQueries.py +++ b/pyfpdb/FpdbSQLQueries.py @@ -599,37 +599,6 @@ class FpdbSQLQueries: ################################ - # Returns all cash game handIds and the money won(winnings is the final pot) - # by the playerId for a single site. - if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'): - self.query['getRingWinningsAllGamesPlayerIdSite'] = """SELECT handId, winnings FROM HandsPlayers - INNER JOIN Players ON HandsPlayers.playerId = Players.id - INNER JOIN Hands ON Hands.id = HandsPlayers.handId - WHERE Players.name = %s AND Players.siteId = %s AND (tourneysPlayersId IS NULL) - ORDER BY handStart""" - elif(self.dbname == 'SQLite'): - #Probably doesn't work. - self.query['getRingWinningsAllGamesPlayerIdSite'] = """SELECT handId, winnings FROM HandsPlayers - INNER JOIN Players ON HandsPlayers.playerId = Players.id - INNER JOIN Hands ON Hands.id = HandsPlayers.handId - WHERE Players.name = %s AND Players.siteId = %s AND (tourneysPlayersId IS NULL) - ORDER BY handStart""" - - # Returns the profit for a given ring game handId, Total pot - money invested by playerId - if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'): - self.query['getRingProfitFromHandId'] = """SELECT SUM(amount) FROM HandsActions - INNER JOIN HandsPlayers ON HandsActions.handPlayerId = HandsPlayers.id - INNER JOIN Players ON HandsPlayers.playerId = Players.id - WHERE Players.name = %s AND HandsPlayers.handId = %s - AND Players.siteId = %s AND (tourneysPlayersId IS NULL)""" - elif(self.dbname == 'SQLite'): - #Probably doesn't work. - self.query['getRingProfitFromHandId'] = """SELECT SUM(amount) FROM HandsActions - INNER JOIN HandsPlayers ON HandsActions.handPlayerId = HandsPlayers.id - INNER JOIN Players ON HandsPlayers.playerId = Players.id - WHERE Players.name = %s AND HandsPlayers.handId = %s - AND Players.siteId = %s AND (tourneysPlayersId IS NULL)""" - if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'): self.query['getPlayerId'] = """SELECT id from Players where name = %s""" elif(self.dbname == 'SQLite'): From 285c7d882493b065b8a2b5695b52db6bf022118c Mon Sep 17 00:00:00 2001 From: Matt Turnbull Date: Sun, 22 Mar 2009 14:53:10 +0000 Subject: [PATCH 12/23] have to supply argv to main() as a list, splitting on whitespace won't work if you supply an argument like a path with a space in it. --- pyfpdb/GuiBulkImport.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py index 2b1fe500..1a62a37d 100755 --- a/pyfpdb/GuiBulkImport.py +++ b/pyfpdb/GuiBulkImport.py @@ -210,11 +210,9 @@ class GuiBulkImport(): def main(argv=None): """main can also be called in the python interpreter, by supplying the command line as the argument. >>>import GuiBulkImport ->>>GuiBulkImport.main("-f ~/data/hands")""" +>>>GuiBulkImport.main(['-f'.'~/data/hands'])""" if argv is None: argv = sys.argv[1:] - else: - argv = argv.split(" ") def destroy(*args): # call back for terminating the main eventloop gtk.main_quit() From 56fe94219df2fbcb8b0d85f8c08f72825c4980f0 Mon Sep 17 00:00:00 2001 From: Matt Turnbull Date: Sun, 22 Mar 2009 14:56:13 +0000 Subject: [PATCH 13/23] This index is used for every insert to check if it is a dupe. Test confirms it's useful : see the last two graphs of http://fpdb.wiki.sourceforge.net/postgresql+tuning --- 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 aaf2d1d2..58fdff05 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -53,7 +53,7 @@ indexes = [ , [ # indexes for postgres (list index 3) {'tab':'Boardcards', 'col':'handId', 'drop':0} , {'tab':'Gametypes', 'col':'siteId', 'drop':0} - , {'tab':'Hands', 'col':'gametypeId', 'drop':1} # todo :1 by sqlcoder , but this is needed for all duplicate checks. test 0 + , {'tab':'Hands', 'col':'gametypeId', 'drop':0} # mct 22/3/09 , {'tab':'Hands', 'col':'siteHandNo', 'drop':0} , {'tab':'HandsActions', 'col':'handplayerId', 'drop':0} , {'tab':'HandsPlayers', 'col':'handId', 'drop':1} From ffb1f926d93e6cf8d468170e67812e1de65ef2b5 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 22 Mar 2009 14:05:58 -0400 Subject: [PATCH 14/23] Better way to keep up with window positions. --- pyfpdb/Mucked.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index 6bc6a58a..9e6cde73 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -345,6 +345,7 @@ class Flop_Mucked(Aux_Window): self.m_windows[i].set_focus_on_map(False) self.eb[i] = gtk.EventBox() self.eb[i].connect("button_press_event", self.button_press_cb) + self.m_windows[i].connect("configure_event", self.configure_event_cb, i) self.m_windows[i].add(self.eb[i]) self.seen_cards[i] = gtk.image_new_from_pixbuf(self.card_images[('B', 'H')]) self.eb[i].add(self.seen_cards[i]) @@ -405,7 +406,6 @@ class Flop_Mucked(Aux_Window): def hide_mucked_cards(self): """Hide the mucked card windows.""" for (i, w) in self.m_windows.iteritems(): - self.positions[i] = w.get_position() w.hide() self.displayed_cards = False @@ -432,6 +432,9 @@ class Flop_Mucked(Aux_Window): window = widget.get_parent() window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time) + def configure_event_cb(self, widget, event, i, *args): + self.positions[i] = widget.get_position() + def expose_all(self): for (i, cards) in self.hud.cards.iteritems(): self.m_windows[i].present() @@ -447,8 +450,6 @@ class Flop_Mucked(Aux_Window): new_locs[self.adj[int(i)]] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y) else: new_locs[i] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y) - print "old locations =", self.params['layout'][self.hud.max] - print "saving locations =", new_locs self.config.edit_aux_layout(self.params['name'], self.hud.max, locations = new_locs) if __name__== "__main__": From 2bffdf25f21abce4d36292984af3c80fce6646ee Mon Sep 17 00:00:00 2001 From: eblade Date: Mon, 23 Mar 2009 05:14:53 -0400 Subject: [PATCH 15/23] comment --- pyfpdb/fpdb_save_to_db.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py index 01bd71cc..d48f669b 100644 --- a/pyfpdb/fpdb_save_to_db.py +++ b/pyfpdb/fpdb_save_to_db.py @@ -73,7 +73,8 @@ def ring_holdem_omaha(config, backend, db, cursor, base, category, site_hand_no, saveActions = False if import_options['saveActions'] == 'False' else True fastStoreHudCache = False if import_options['fastStoreHudCache'] == 'False' else True - # print "DEBUG: saveActions = '%s' fastStoreHudCache = '%s'"%(saveActions, fastStoreHudCache) +# print "DEBUG: saveActions = '%s' fastStoreHudCache = '%s'"%(saveActions, fastStoreHudCache) +# print "DEBUG: import_options = ", import_options t0 = time() fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) From 5e5e79f08ad331b40dfe2263ff26bf8d78e4f22f Mon Sep 17 00:00:00 2001 From: Worros Date: Mon, 23 Mar 2009 22:18:22 +0900 Subject: [PATCH 16/23] Fix typo --- pyfpdb/fpdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 5cdd3d3b..b5931bde 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -337,7 +337,7 @@ class fpdb: new_ps_thread=GuiPositionalStats.GuiPositionalStats(self.db, self.config, self.querydict) self.threads.append(new_ps_thread) ps_tab=new_ps_thread.get_vbox() - self.add_and_display_tab(ps_tab, "Ppositional Stats") + self.add_and_display_tab(ps_tab, "Positional Stats") def tab_main_help(self, widget, data): From 2f4783b50b5d0f51ec7610b89e323565ed8553f0 Mon Sep 17 00:00:00 2001 From: eblade Date: Mon, 23 Mar 2009 17:13:32 -0400 Subject: [PATCH 17/23] mucked: present() = show(), moved a line out of a loop fpdb_simple: fix cardMap to understand "0", for stud games --- pyfpdb/Mucked.py | 6 +++--- pyfpdb/fpdb_simple.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index 9e6cde73..69acf7e7 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -376,7 +376,7 @@ class Flop_Mucked(Aux_Window): self.seen_cards[i].set_from_pixbuf(scratch) # self.m_windows[i].show_all() self.m_windows[i].resize(1,1) - self.m_windows[i].present() + self.m_windows[i].show() self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back self.displayed_cards = True @@ -407,7 +407,7 @@ class Flop_Mucked(Aux_Window): """Hide the mucked card windows.""" for (i, w) in self.m_windows.iteritems(): w.hide() - self.displayed_cards = False + self.displayed_cards = False def button_press_cb(self, widget, event, *args): """Handle button clicks in the event boxes.""" @@ -437,7 +437,7 @@ class Flop_Mucked(Aux_Window): def expose_all(self): for (i, cards) in self.hud.cards.iteritems(): - self.m_windows[i].present() + self.m_windows[i].show() self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back self.displayed_cards = True diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index aa876804..27ce23da 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -513,7 +513,8 @@ def convertCardValues(arr): map(convertCardValuesBoard, arr) #end def convertCardValues -card_map = { "2": 2, "3" : 3, "4" : 4, "5" : 5, "6" : 6, "7" : 7, "8" : 8, "9" : 9, "T" : 10, "J" : 11, "Q" : 12, "K" : 13, "A" : 14} +# a 0-card is one in a stud game that we did not see or was not shown +card_map = { "0": 0, "2": 2, "3" : 3, "4" : 4, "5" : 5, "6" : 6, "7" : 7, "8" : 8, "9" : 9, "T" : 10, "J" : 11, "Q" : 12, "K" : 13, "A" : 14} #converts the strings in the given array to ints (changes the passed array, no returning). see table design for conversion details def convertCardValuesBoard(arr): From a863743974eb095a75e17f955b691ebdf38635af Mon Sep 17 00:00:00 2001 From: eblade Date: Mon, 23 Mar 2009 19:22:04 -0400 Subject: [PATCH 18/23] move move() under the line where position to move to is stored, instead of calculating position twice in two lines --- pyfpdb/Mucked.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index 69acf7e7..9f8d6244 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -349,8 +349,8 @@ class Flop_Mucked(Aux_Window): self.m_windows[i].add(self.eb[i]) self.seen_cards[i] = gtk.image_new_from_pixbuf(self.card_images[('B', 'H')]) self.eb[i].add(self.seen_cards[i]) - self.m_windows[i].move(int(x) + self.hud.table.x, int(y) + self.hud.table.y) self.positions[i] = (int(x) + self.hud.table.x, int(y) + self.hud.table.y) + self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) self.m_windows[i].set_opacity(float(self.params['opacity'])) self.m_windows[i].show_all() self.m_windows[i].hide() From dca1ea755411f297b550db3c3932729df2b09e2a Mon Sep 17 00:00:00 2001 From: eblade Date: Mon, 23 Mar 2009 23:49:09 -0400 Subject: [PATCH 19/23] fix for filterAnteBLindFold to return it's value --- 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 e5d60862..5b468f94 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -613,7 +613,7 @@ def filterAnteBlindFold(site,hand): if foldeeName in line: hand[i] = None - hand = [line for line in hand if line] + return [line for line in hand if line] #end def filterAnteFold def stripEOLspaces(str): From 65e208706232c9a62619711e08d2453eeee66c1c Mon Sep 17 00:00:00 2001 From: eblade Date: Tue, 24 Mar 2009 00:30:27 -0400 Subject: [PATCH 20/23] fix fix --- pyfpdb/fpdb_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 2c33a841..059186b1 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -354,7 +354,7 @@ class Importer: else: #normal processing isTourney=fpdb_simple.isTourney(hand[0]) if not isTourney: - fpdb_simple.filterAnteBlindFold(site,hand) + hand = fpdb_simple.filterAnteBlindFold(site,hand) self.hand=hand try: From d4165a51094ed0830f3abb1162bb5f432b749bf9 Mon Sep 17 00:00:00 2001 From: eblade Date: Tue, 24 Mar 2009 05:19:20 -0400 Subject: [PATCH 21/23] ongoing effort to squeeze a couple more cpu cycles out of the hud creation process --- pyfpdb/Hud.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 20750b96..e3e008cd 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -82,7 +82,7 @@ class Hud: font = "Sans" if font_size == None: font_size = "8" - self.font = pango.FontDescription(font + " " + font_size) + self.font = pango.FontDescription("%s %s" % (font, font_size)) # do we need to add some sort of condition here for dealing with a request for a font that doesn't exist? game_params = config.get_game_parameters(self.poker_game) @@ -173,10 +173,11 @@ class Hud: self.main_window.move(x, y) adj = self.adj_seats(self.hand, self.config) loc = self.config.get_locations(self.table.site, self.max) - for i in xrange(1, self.max + 1): - (x, y) = loc[adj[i]] - if i in self.stat_windows: - self.stat_windows[i].relocate(x, y) + for i, w in enumerate(self.stat_windows): + if not type(w) == int: # how do we get pure ints in this list?? + (x, y) = loc[adj[i]] + w.relocate(x, y) + return True def on_button_press(self, widget, event): @@ -286,10 +287,12 @@ class Hud: font = self.font) self.stats = [] - for i in xrange(0, config.supported_games[self.poker_game].rows + 1): - row_list = [''] * config.supported_games[self.poker_game].cols + game = config.supported_games[self.poker_game] + + for i in xrange(0, game.rows + 1): + row_list = [''] * game.cols self.stats.append(row_list) - for stat in config.supported_games[self.poker_game].stats: + for stat in game.stats: 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 @@ -314,7 +317,7 @@ class Hud: for c in xrange(0, config.supported_games[self.poker_game].cols): this_stat = config.supported_games[self.poker_game].stats[self.stats[r][c]] number = Stats.do_stat(self.stat_dict, player = self.stat_dict[s]['player_id'], stat = self.stats[r][c]) - statstring = this_stat.hudprefix + str(number[1]) + this_stat.hudsuffix + statstring = "%s%s%s" % (this_stat.hudprefix, str(number[1]), this_stat.hudsuffix) if this_stat.hudcolor != "": self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor'])) @@ -324,8 +327,7 @@ class Hud: if statstring != "xxx": # is there a way to tell if this particular stat window is visible already, or no? self.stat_windows[self.stat_dict[s]['seat']].window.show_all() # self.reposition_windows() - tip = self.stat_dict[s]['screen_name'] + "\n" + number[5] + "\n" + \ - number[3] + ", " + number[4] + tip = "%s\n%s\n%s, %s" % (self.stat_dict[s]['screen_name'], number[5], number[3], number[4]) Stats.do_tip(self.stat_windows[self.stat_dict[s]['seat']].e_box[r][c], tip) def topify_window(self, window): @@ -408,7 +410,7 @@ class Stat_Window: self.window.set_property("skip-taskbar-hint", True) self.window.set_transient_for(parent.main_window) - self.grid = gtk.Table(rows = self.game.rows, columns = self.game.cols, homogeneous = False) + self.grid = gtk.Table(rows = game.rows, columns = game.cols, homogeneous = False) self.window.add(self.grid) self.window.modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) @@ -418,12 +420,12 @@ class Stat_Window: usegtkframes = self.useframes e_box = self.e_box label = self.label - for r in xrange(self.game.rows): + for r in xrange(game.rows): if usegtkframes: self.frame.append([]) e_box.append([]) label.append([]) - for c in xrange(self.game.cols): + for c in xrange(game.cols): if usegtkframes: self.frame[r].append( gtk.Frame() ) e_box[r].append( gtk.EventBox() ) From d168618b4b06b90787b48cc112631232c942e29e Mon Sep 17 00:00:00 2001 From: eblade Date: Tue, 24 Mar 2009 05:55:07 -0400 Subject: [PATCH 22/23] try to squeeze a few more cycles out .. seems to not be locking up anymore, though i could be running good on that right now --- pyfpdb/Hud.py | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index e3e008cd..95c6c18e 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -197,12 +197,12 @@ class Hud: s.window.destroy() self.stat_windows = {} # also kill any aux windows - [aux.destroy() for aux in self.aux_windows] + (aux.destroy() for aux in self.aux_windows) self.aux_windows = [] def reposition_windows(self, *args): if self.stat_windows != {} and len(self.stat_windows) > 0: - map(lambda x: x.window.move(x.x, x.y), self.stat_windows.itervalues()) + (x.window.move(x.x, x.y) for x in self.stat_windows.itervalues() if type(x) != int) return True def debug_stat_windows(self, *args): @@ -218,7 +218,7 @@ class Hud: new_layout[self.stat_windows[sw].adj - 1] = new_loc self.config.edit_layout(self.table.site, self.max, locations = new_layout) # ask each aux to save its layout back to the config object - [aux.save_layout() for aux in self.aux_windows] + (aux.save_layout() for aux in self.aux_windows) # save the config object back to the file print "saving new xml file" self.config.save() @@ -228,9 +228,9 @@ class Hud: # Need range here, not xrange -> need the actual list adj = range(0, self.max + 1) # default seat adjustments = no adjustment # does the user have a fav_seat? - try: - sys.stderr.write("site = %s, max = %d, fav seat = %d\n" % (self.table.site, self.max, config.supported_sites[self.table.site].layout[self.max].fav_seat)) - if int(config.supported_sites[self.table.site].layout[self.max].fav_seat) > 0: + if int(config.supported_sites[self.table.site].layout[self.max].fav_seat) > 0: + try: + sys.stderr.write("site = %s, max = %d, fav seat = %d\n" % (self.table.site, self.max, config.supported_sites[self.table.site].layout[self.max].fav_seat)) fav_seat = config.supported_sites[self.table.site].layout[self.max].fav_seat sys.stderr.write("found fav seat = %d\n" % fav_seat) # actual_seat = self.db_connection.get_actual_seat(hand, config.supported_sites[self.table.site].screen_name) @@ -238,12 +238,14 @@ class Hud: sys.stderr.write("found actual seat = %d\n" % actual_seat) for i in xrange(0, self.max + 1): j = actual_seat + i - if j > self.max: j = j - self.max + if j > self.max: + j = j - self.max adj[j] = fav_seat + i - if adj[j] > self.max: adj[j] = adj[j] - self.max - except Exception, inst: - sys.stderr.write("exception in adj!!!\n\n") - sys.stderr.write("error is %s" % inst) # __str__ allows args to printed directly + if adj[j] > self.max: + adj[j] = adj[j] - self.max + except Exception, inst: + sys.stderr.write("exception in adj!!!\n\n") + sys.stderr.write("error is %s" % inst) # __str__ allows args to printed directly return adj def get_actual_seat(self, name): @@ -306,29 +308,30 @@ class Hud: self.update_table_position() for s in self.stat_dict: + statd = self.stat_dict[s] try: self.stat_windows[self.stat_dict[s]['seat']].player_id = self.stat_dict[s]['player_id'] except: # omg, we have more seats than stat windows .. damn poker sites with incorrect max seating info .. let's force 10 here self.max = 10 self.create(hand, config, self.stat_dict, self.cards) - self.stat_windows[self.stat_dict[s]['seat']].player_id = self.stat_dict[s]['player_id'] + self.stat_windows[statd['seat']].player_id = statd['player_id'] for r in xrange(0, config.supported_games[self.poker_game].rows): for c in xrange(0, config.supported_games[self.poker_game].cols): this_stat = config.supported_games[self.poker_game].stats[self.stats[r][c]] - number = Stats.do_stat(self.stat_dict, player = self.stat_dict[s]['player_id'], stat = self.stats[r][c]) + number = Stats.do_stat(self.stat_dict, player = statd['player_id'], stat = self.stats[r][c]) statstring = "%s%s%s" % (this_stat.hudprefix, str(number[1]), this_stat.hudsuffix) + window = self.stat_windows[statd['seat']] if this_stat.hudcolor != "": self.label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(self.colors['hudfgcolor'])) - self.stat_windows[self.stat_dict[s]['seat']].label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.hudcolor)) - - self.stat_windows[self.stat_dict[s]['seat']].label[r][c].set_text(statstring) + window.label[r][c].modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse(this_stat.hudcolor)) + + window.label[r][c].set_text(statstring) if statstring != "xxx": # is there a way to tell if this particular stat window is visible already, or no? - self.stat_windows[self.stat_dict[s]['seat']].window.show_all() -# self.reposition_windows() - tip = "%s\n%s\n%s, %s" % (self.stat_dict[s]['screen_name'], number[5], number[3], number[4]) - Stats.do_tip(self.stat_windows[self.stat_dict[s]['seat']].e_box[r][c], tip) + window.window.show_all() + tip = "%s\n%s\n%s, %s" % (statd['screen_name'], number[5], number[3], number[4]) + Stats.do_tip(window.e_box[r][c], tip) def topify_window(self, window): """Set the specified gtk window to stayontop in MS Windows.""" From 42f2cb049da892787628090c4212e2c711d497f6 Mon Sep 17 00:00:00 2001 From: eblade Date: Tue, 24 Mar 2009 06:04:00 -0400 Subject: [PATCH 23/23] add set_focus_on_map calls to hud window creation, doesn't seem to do much, but feels correct --- pyfpdb/Hud.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 95c6c18e..3fa677b6 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -102,6 +102,7 @@ class Hud: self.main_window.set_title("%s FPDBHUD" % (self.table.name)) self.main_window.set_decorated(False) self.main_window.set_opacity(self.colors["hudopacity"]) + self.main_window.set_focus_on_map(False) self.ebox = gtk.EventBox() self.label = gtk.Label("FPDB Menu (Right Click)\nLeft-drag to move") @@ -412,6 +413,7 @@ class Stat_Window: self.window.set_title("%s" % seat) self.window.set_property("skip-taskbar-hint", True) self.window.set_transient_for(parent.main_window) + self.window.set_focus_on_map(False) self.grid = gtk.Table(rows = game.rows, columns = game.cols, homogeneous = False) self.window.add(self.grid)