From e0a406e66d3e7bcc6a689b55bece50e74c25248f Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 14 Mar 2009 12:54:52 -0400 Subject: [PATCH 01/13] Make Configiuration.py executable. --- pyfpdb/Configuration.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 pyfpdb/Configuration.py diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py old mode 100644 new mode 100755 From 9fca5a75b24ce81403ceceb037d94586f6b5f075 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 15 Mar 2009 15:27:47 -0400 Subject: [PATCH 02/13] Allow saving of aux_window layouts. --- pyfpdb/Configuration.py | 27 +++++++++++++++------- pyfpdb/Hud.py | 9 ++++++-- pyfpdb/Mucked.py | 50 ++++++++++++++++++++++------------------- 3 files changed, 53 insertions(+), 33 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 2af44b7d..d632c486 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -391,9 +391,14 @@ class Config: return layout_node def get_location_node(self, layout_node, seat): - for location_node in layout_node.getElementsByTagName("location"): - if int( location_node.getAttribute("seat") ) == int( seat ): - return location_node + if seat == "common": + for location_node in layout_node.getElementsByTagName("location"): + if location_node.hasAttribute("common"): + return location_node + else: + for location_node in layout_node.getElementsByTagName("location"): + if int( location_node.getAttribute("seat") ) == int( seat ): + return location_node def save(self, file = None): if not file == None: @@ -420,12 +425,18 @@ class Config: def edit_aux_layout(self, aux_name, max, width = None, height = None, locations = None): aux_node = self.get_aux_node(aux_name) layout_node = self.get_layout_node(aux_node, max) - if layout_node == None: return - for i in range(1, max + 1): + if layout_node == None: + print "aux node not found" + return + print "editing locations =", locations + for (i, pos) in locations.iteritems(): location_node = self.get_location_node(layout_node, i) - location_node.setAttribute("x", str( locations[i-1][0] )) - location_node.setAttribute("y", str( locations[i-1][1] )) - self.aux_windows[aux_name].layout[max].location[i] = ( locations[i-1][0], locations[i-1][1] ) + location_node.setAttribute("x", str( locations[i][0] )) + location_node.setAttribute("y", str( locations[i][1] )) + if i == "common": + self.aux_windows[aux_name].layout[max].common = ( locations[i][0], locations[i][1] ) + else: + self.aux_windows[aux_name].layout[max].location[i] = ( locations[i][0], locations[i][1] ) def get_db_parameters(self, name = None): if name == None: name = 'fpdb' diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index f47d93e9..6d594b5b 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -200,8 +200,8 @@ class Hud: 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) + if self.stat_windows != {} and len(self.stat_windows) > 0: + map(lambda x: x.window.move(x.x, x.y), self.stat_windows.itervalues()) return True def debug_stat_windows(self, *args): @@ -216,6 +216,11 @@ class Hud: new_loc = (loc[0] - self.table.x, loc[1] - self.table.y) 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 + for aux in self.aux_windows: + aux.save_layout() +# save the config object back to the file + print "saving new xml file" self.config.save() def adj_seats(self, hand, config): diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index 90af4b8f..faf0fe3a 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -49,6 +49,9 @@ class Aux_Window: def create(self, *parms): pass + def save_layout(self, *args): + pass + def destroy(self): self.container.destroy() @@ -312,12 +315,13 @@ class Flop_Mucked(Aux_Window): def __init__(self, hud, config, params): self.hud = hud # hud object that this aux window supports self.config = config # configuration object for this aux window to use - self.params = params # hash aux params from config + self.params = params # dict aux params from config + self.positions = {} # dict of window positions + self.displayed_cards = False self.card_images = self.get_card_images() def create(self): - - adj = self.hud.adj_seats(0, self.config) + self.adj = self.hud.adj_seats(0, self.config) loc = self.config.get_aux_locations(self.params['name'], int(self.hud.max)) self.m_windows = {} # windows to put the card images in @@ -328,7 +332,7 @@ class Flop_Mucked(Aux_Window): if i == 'common': (x, y) = self.params['layout'][self.hud.max].common else: - (x, y) = loc[adj[i]] + (x, y) = loc[self.adj[i]] self.m_windows[i] = gtk.Window() self.m_windows[i].set_decorated(False) self.m_windows[i].set_property("skip-taskbar-hint", True) @@ -340,6 +344,7 @@ class Flop_Mucked(Aux_Window): 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].set_opacity(float(self.params['opacity'])) self.m_windows[i].show_all() self.m_windows[i].hide() @@ -350,11 +355,9 @@ class Flop_Mucked(Aux_Window): def update_gui(self, new_hand_id): """Prepare and show the mucked cards.""" - pos = {} - for i, w in self.m_windows.iteritems(): - pos[i] = w.get_position() # I hate this. I don't know why I have to save position and then move back - self.hide_mucked_cards() - displayed_cards = False + if self.displayed_cards: + self.hide_mucked_cards() + self.displayed_cards = False for (i, cards) in self.hud.cards.iteritems(): if self.has_cards(cards): # scratch is a working pixbuf, used to assemble the image @@ -370,11 +373,11 @@ class Flop_Mucked(Aux_Window): x = x + int(self.params['card_wd']) self.seen_cards[i].set_from_pixbuf(scratch) # self.m_windows[i].show_all() - self.m_windows[i].move(pos[i][0], pos[i][1]) # here is where I move back self.m_windows[i].present() - displayed_cards = True + self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back + self.displayed_cards = True - if displayed_cards and float(self.params['timeout']) > 0: + if self.displayed_cards and float(self.params['timeout']) > 0: gobject.timeout_add(int(1000*float(self.params['timeout'])), self.hide_mucked_cards) def destroy(self): @@ -385,8 +388,10 @@ class Flop_Mucked(Aux_Window): def hide_mucked_cards(self): """Hide the mucked card windows.""" # this is the callback from the timeout - for w in self.m_windows.values(): + for (i, w) in self.m_windows.iteritems(): + self.positions[i] = w.get_position() w.hide() + self.displayed_cards = False return False # this tells the system to NOT run this timeout again def button_press_cb(self, widget, event, *args): @@ -403,17 +408,16 @@ class Flop_Mucked(Aux_Window): def save_layout(self, *args): """Save new layout back to the aux element in the config file.""" -# similar to same method in stat_windows - new_layout = [(0, 0)] * self.hud.max - for (i, w) in self.m_windows.iteritems(): - (x, y) = w.get_position() - new_loc = (x - self.hud.table.x, y - self.hud.table.y) - if i != "common": - new_layout[self.hud.stat_windows[int(i)].adj - 1] = new_loc + new_locs = {} + print "adj =", self.adj + for (i, pos) in self.positions.iteritems(): + if i != 'common': + new_locs[self.adj[int(i)]] = (pos[0] - self.hud.table.x, pos[1] - self.hud.table.y) else: - pass - self.config.edit_layout(self.table.site, self.max, locations = new_layout) - self.config.save() + 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 6f927e6b7ba7ab6b7805948af350118b2a8f25f4 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 15 Mar 2009 15:54:22 -0400 Subject: [PATCH 03/13] saveActions and fastStoreHudCache added to import element. --- pyfpdb/Configuration.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index d632c486..57692180 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -205,9 +205,18 @@ class Import: self.interval = node.getAttribute("interval") self.callFpdbHud = node.getAttribute("callFpdbHud") self.hhArchiveBase = node.getAttribute("hhArchiveBase") + if node.hasAttribute("saveActions"): + self.saveActions = node.getAttribute("saveActions") + else: + self.saveActions = False + if node.hasAttribute("fastStoreHudCache"): + self.fastStoreHudCache = node.getAttribute("fastStoreHudCache") + else: + self.saveActions = False def __str__(self): - return " interval = %s\n callFpdbHud = %s\n hhArchiveBase = %s" % (self.interval, self.callFpdbHud, self.hhArchiveBase) + return " interval = %s\n callFpdbHud = %s\n hhArchiveBase = %s\n saveActions = %s\n fastStoreHudCache = %s\n" \ + % (self.interval, self.callFpdbHud, self.hhArchiveBase, self.saveActions, self.saveActions) class Tv: def __init__(self, node): @@ -488,13 +497,17 @@ class Config: def get_import_parameters(self): imp = {} try: - imp['callFpdbHud'] = self.imp.callFpdbHud - imp['interval'] = self.imp.interval - imp['hhArchiveBase'] = self.imp.hhArchiveBase + imp['callFpdbHud'] = self.imp.callFpdbHud + imp['interval'] = self.imp.interval + imp['hhArchiveBase'] = self.imp.hhArchiveBase + imp['saveActions'] = self.imp.saveActions + imp['fastStoreHudCache'] = self.imp.fastStoreHudCache except: # Default params imp['callFpdbHud'] = True imp['interval'] = 10 imp['hhArchiveBase'] = "~/.fpdb/HandHistories/" + imp['saveActions'] = False + imp['fastStoreHudCache'] = False return imp def get_default_paths(self, site = "PokerStars"): @@ -700,9 +713,9 @@ if __name__== "__main__": print c.get_aux_parameters(mw) print "mucked locations =", c.get_aux_locations('mucked', 9) - c.edit_aux_layout('mucked', 9, locations = [(487, 113), (555, 469), (572, 276), (522, 345), - (333, 354), (217, 341), (150, 273), (150, 169), (230, 115)]) - print "mucked locations =", c.get_aux_locations('mucked', 9) +# c.edit_aux_layout('mucked', 9, locations = [(487, 113), (555, 469), (572, 276), (522, 345), +# (333, 354), (217, 341), (150, 273), (150, 169), (230, 115)]) +# print "mucked locations =", c.get_aux_locations('mucked', 9) for site in c.supported_sites.keys(): print "site = ", site, From 6d292c50d9e7c49f212e8c136b2ad4b47fef6e94 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 15 Mar 2009 17:40:01 -0400 Subject: [PATCH 04/13] Use saveActions and fastStoreHudCache in fpdb_import, etc. --- pyfpdb/fpdb_import.py | 2 +- pyfpdb/fpdb_parse_logic.py | 10 +++--- pyfpdb/fpdb_save_to_db.py | 71 ++++++++++++++++++++++++++++++++++---- 3 files changed, 71 insertions(+), 12 deletions(-) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index ef0894e3..12575b4f 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -352,7 +352,7 @@ class Importer: try: handsId=fpdb_parse_logic.mainParser(self.settings['db-backend'], self.fdb.db - ,self.fdb.cursor, site, category, hand) + ,self.fdb.cursor, site, category, hand, self.config) self.fdb.db.commit() stored+=1 diff --git a/pyfpdb/fpdb_parse_logic.py b/pyfpdb/fpdb_parse_logic.py index dab3bcc4..9dd54f83 100644 --- a/pyfpdb/fpdb_parse_logic.py +++ b/pyfpdb/fpdb_parse_logic.py @@ -21,7 +21,7 @@ import fpdb_simple import fpdb_save_to_db #parses a holdem hand -def mainParser(backend, db, cursor, site, category, hand): +def mainParser(backend, db, cursor, site, category, hand, config): category=fpdb_simple.recogniseCategory(hand[0]) if (category=="holdem" or category=="omahahi" or category=="omahahilo"): base="hold" @@ -150,7 +150,7 @@ def mainParser(backend, db, cursor, site, category, hand): if base=="hold": result = fpdb_save_to_db.tourney_holdem_omaha( - backend, db, cursor, base, category, siteTourneyNo, buyin + config, backend, db, cursor, base, category, siteTourneyNo, buyin , fee, knockout, entries, prizepool, tourneyStartTime , payin_amounts, ranks, tourneyTypeId, siteID, siteHandNo , gametypeID, handStartTime, names, playerIDs, startCashes @@ -159,7 +159,7 @@ def mainParser(backend, db, cursor, site, category, hand): , actionNos, hudImportData, maxSeats, tableName, seatNos) elif base=="stud": result = fpdb_save_to_db.tourney_stud( - backend, db, cursor, base, category, siteTourneyNo + config, backend, db, cursor, base, category, siteTourneyNo , buyin, fee, knockout, entries, prizepool, tourneyStartTime , payin_amounts, ranks, tourneyTypeId, siteID, siteHandNo , gametypeID, handStartTime, names, playerIDs, startCashes @@ -171,7 +171,7 @@ def mainParser(backend, db, cursor, site, category, hand): else: if base=="hold": result = fpdb_save_to_db.ring_holdem_omaha( - backend, db, cursor, base, category, siteHandNo + config, backend, db, cursor, base, category, siteHandNo , gametypeID, handStartTime, names, playerIDs , startCashes, positions, cardValues, cardSuits , boardValues, boardSuits, winnings, rakes @@ -179,7 +179,7 @@ def mainParser(backend, db, cursor, site, category, hand): , hudImportData, maxSeats, tableName, seatNos) elif base=="stud": result = fpdb_save_to_db.ring_stud( - backend, db, cursor, base, category, siteHandNo, gametypeID + config, backend, db, cursor, base, category, siteHandNo, gametypeID , handStartTime, names, playerIDs, startCashes, antes , cardValues, cardSuits, winnings, rakes, actionTypes, allIns , actionAmounts, actionNos, hudImportData, maxSeats, tableName diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py index ba734e80..a656ec00 100644 --- a/pyfpdb/fpdb_save_to_db.py +++ b/pyfpdb/fpdb_save_to_db.py @@ -26,18 +26,29 @@ MYSQL_INNODB=2 PGSQL=3 SQLITE=4 -fastStoreHudCache=False # set this to True to test the new storeHudCache routine +fastStoreHudCache=True # set this to True to test the new storeHudCache routine -saveActions=True # set this to False to avoid storing action data +saveActions=False # 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 #stores a stud/razz hand into the database -def ring_stud(backend, db, cursor, base, category, site_hand_no, gametype_id, hand_start_time +def ring_stud(config, backend, db, cursor, base, category, site_hand_no, gametype_id, hand_start_time ,names, player_ids, start_cashes, antes, card_values, card_suits, winnings, rakes ,action_types, allIns, action_amounts, actionNos, hudImportData, maxSeats, tableName ,seatNos): + + import_options = config.get_import_parameters() + if import_options['saveActions'] == 'True': + saveActions = True + else: + saveActions = False + if import_options['fastStoreHudCache'] == 'True': + fastStoreHudCache = True + else: + fastStoreHudCache = False + fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id @@ -56,11 +67,27 @@ def ring_stud(backend, db, cursor, base, category, site_hand_no, gametype_id, ha return hands_id #end def ring_stud -def ring_holdem_omaha(backend, db, cursor, base, category, site_hand_no, gametype_id +def ring_holdem_omaha(config, backend, db, cursor, base, category, site_hand_no, gametype_id ,hand_start_time, names, player_ids, start_cashes, positions, card_values ,card_suits, board_values, board_suits, winnings, rakes, action_types, allIns ,action_amounts, actionNos, hudImportData, maxSeats, tableName, seatNos): """stores a holdem/omaha hand into the database""" + + import_options = config.get_import_parameters() + if import_options['saveActions'] == 'True': + saveActions = True + else: + saveActions = False + if import_options['fastStoreHudCache'] == 'True': + fastStoreHudCache = True + else: + fastStoreHudCache = False + + fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) + + hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id + ,hand_start_time, names, tableName, maxSeats) + t0 = time() fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) t1 = time() @@ -89,7 +116,7 @@ def ring_holdem_omaha(backend, db, cursor, base, category, site_hand_no, gametyp return hands_id #end def ring_holdem_omaha -def tourney_holdem_omaha(backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout +def tourney_holdem_omaha(config, backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout ,entries, prizepool, tourney_start, payin_amounts, ranks, tourneyTypeId ,siteId #end of tourney specific params ,site_hand_no, gametype_id, hand_start_time, names, player_ids @@ -97,6 +124,22 @@ def tourney_holdem_omaha(backend, db, cursor, base, category, siteTourneyNo, buy ,board_suits, winnings, rakes, action_types, allIns, action_amounts ,actionNos, hudImportData, maxSeats, tableName, seatNos): """stores a tourney holdem/omaha hand into the database""" + + import_options = config.get_import_parameters() + if import_options['saveActions'] == 'True': + saveActions = True + else: + saveActions = False + if import_options['fastStoreHudCache'] == 'True': + fastStoreHudCache = True + else: + fastStoreHudCache = False + + fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) + + hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id + ,hand_start_time, names, tableName, maxSeats) + fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) fpdb_simple.fill_board_cards(board_values, board_suits) @@ -123,12 +166,28 @@ def tourney_holdem_omaha(backend, db, cursor, base, category, siteTourneyNo, buy return hands_id #end def tourney_holdem_omaha -def tourney_stud(backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries +def tourney_stud(config, backend, db, cursor, base, category, siteTourneyNo, buyin, fee, knockout, entries ,prizepool, tourneyStartTime, payin_amounts, ranks, tourneyTypeId, siteId ,siteHandNo, gametypeId, handStartTime, names, playerIds, startCashes, antes ,cardValues, cardSuits, winnings, rakes, actionTypes, allIns, actionAmounts ,actionNos, hudImportData, maxSeats, tableName, seatNos): #stores a tourney stud/razz hand into the database + + import_options = config.get_import_parameters() + if import_options['saveActions'] == 'True': + saveActions = True + else: + saveActions = False + if import_options['fastStoreHudCache'] == 'True': + fastStoreHudCache = True + else: + fastStoreHudCache = False + + fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) + + hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id + ,hand_start_time, names, tableName, maxSeats) + fpdb_simple.fillCardArrays(len(names), base, category, cardValues, cardSuits) tourney_id=fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourneyStartTime) From 66e734588ce2e061f1d9994d1e92de06a9f01ead Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 16 Mar 2009 18:00:57 -0400 Subject: [PATCH 05/13] Fix extra lines in previous commit. --- pyfpdb/fpdb_save_to_db.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py index a656ec00..b215f7ee 100644 --- a/pyfpdb/fpdb_save_to_db.py +++ b/pyfpdb/fpdb_save_to_db.py @@ -83,11 +83,6 @@ def ring_holdem_omaha(config, backend, db, cursor, base, category, site_hand_no, else: fastStoreHudCache = False - fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) - - hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id - ,hand_start_time, names, tableName, maxSeats) - t0 = time() fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) t1 = time() @@ -135,11 +130,6 @@ def tourney_holdem_omaha(config, backend, db, cursor, base, category, siteTourne else: fastStoreHudCache = False - fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) - - hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id - ,hand_start_time, names, tableName, maxSeats) - fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) fpdb_simple.fill_board_cards(board_values, board_suits) @@ -182,11 +172,6 @@ def tourney_stud(config, backend, db, cursor, base, category, siteTourneyNo, buy fastStoreHudCache = True else: fastStoreHudCache = False - - fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) - - hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id - ,hand_start_time, names, tableName, maxSeats) fpdb_simple.fillCardArrays(len(names), base, category, cardValues, cardSuits) From bc2277af74672a881eac843b5b0ec8b9c3b30cd5 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 16 Mar 2009 18:23:45 -0400 Subject: [PATCH 06/13] Comment out index dropping for postgres--prevent hang. --- pyfpdb/fpdb_simple.py | 73 ++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 29 deletions(-) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 0d741a43..6ac28bd1 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -156,12 +156,16 @@ def prepareBulkImport(fdb): except: pass elif fdb.backend == PGSQL: - print "dropping pg fk", fk['fktab'], fk['fkcol'] - try: - fdb.cursor.execute("alter table " + fk['fktab'] + " drop constraint " - + fk['fktab'] + '_' + fk['fkcol'] + '_fkey') - except: - pass +# DON'T FORGET TO RECREATE THEM!! + print "Index dropping disabled for postgresql." +# 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 " + fk['fktab'] + " drop constraint " \ +# + fk['fktab'] + '_' + fk['fkcol'] + '_fkey' +# except: +# pass else: print "Only MySQL and Postgres supported so far" return -1 @@ -175,12 +179,17 @@ def prepareBulkImport(fdb): except: pass elif fdb.backend == PGSQL: - print "dropping pg index ", idx['tab'], idx['col'] - # mod to use tab_col for index name? - try: - fdb.cursor.execute( "drop index %s_%s_idx" % (idx['tab'],idx['col']) ) - except: - pass +# DON'T FORGET TO RECREATE THEM!! + print "Index dropping disabled for postgresql." +# print "dropping pg index ", idx['tab'], idx['col'] +# # mod to use tab_col for index name? +# try: +# pass +# 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'] +# except: +# pass else: print "Only MySQL and Postgres supported so far" return -1 @@ -219,14 +228,19 @@ def afterBulkImport(fdb): except: pass elif fdb.backend == PGSQL: - print "creating fk ", fk['fktab'], fk['fkcol'], "->", fk['rtab'], fk['rcol'] - try: - fdb.cursor.execute("alter table " + fk['fktab'] + " add constraint " - + fk['fktab'] + '_' + fk['fkcol'] + '_fkey' - + " foreign key (" + fk['fkcol'] - + ") references " + fk['rtab'] + "(" + fk['rcol'] + ")") - except: - pass + pass +# print "creating fk ", fk['fktab'], fk['fkcol'], "->", fk['rtab'], fk['rcol'] +# try: +# print "alter table " + fk['fktab'] + " add constraint " \ +# + fk['fktab'] + '_' + fk['fkcol'] + '_fkey' \ +# + " foreign key (" + fk['fkcol'] \ +# + ") references " + fk['rtab'] + "(" + fk['rcol'] + ")" +# fdb.cursor.execute("alter table " + fk['fktab'] + " add constraint " +# + fk['fktab'] + '_' + fk['fkcol'] + '_fkey' +# + " foreign key (" + fk['fkcol'] +# + ") references " + fk['rtab'] + "(" + fk['rcol'] + ")") +# except: +# pass else: print "Only MySQL and Postgres supported so far" return -1 @@ -241,15 +255,16 @@ def afterBulkImport(fdb): except: pass elif fdb.backend == PGSQL: - # mod to use tab_col for index name? - print "creating pg index ", idx['tab'], idx['col'] - try: - print "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col']) - fdb.cursor.execute( "create index %s_%s_idx on %s(%s)" - % (idx['tab'], idx['col'], idx['tab'], idx['col']) ) - except: - print " ERROR! :-(" - pass + pass +# # mod to use tab_col for index name? +# print "creating pg index ", idx['tab'], idx['col'] +# try: +# print "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col']) +# fdb.cursor.execute( "create index %s_%s_idx on %s(%s)" +# % (idx['tab'], idx['col'], idx['tab'], idx['col']) ) +# except: +# print " ERROR! :-(" +# pass else: print "Only MySQL and Postgres supported so far" return -1 From 067373b12821421556a44054fd18bd2284c6c9d3 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 16 Mar 2009 21:07:11 -0400 Subject: [PATCH 07/13] Fixed defaults for saveActions and fastStoreHudCache. --- pyfpdb/Configuration.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 57692180..86087bfc 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -506,8 +506,8 @@ class Config: imp['callFpdbHud'] = True imp['interval'] = 10 imp['hhArchiveBase'] = "~/.fpdb/HandHistories/" - imp['saveActions'] = False - imp['fastStoreHudCache'] = False + imp['saveActions'] = True + imp['fastStoreHudCache'] = True return imp def get_default_paths(self, site = "PokerStars"): From 466f6c09c2f201ae0c650de56bc95ce128e97be6 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 16 Mar 2009 23:34:00 -0400 Subject: [PATCH 08/13] Make a whole bunch of config defaults work as desired. --- pyfpdb/Configuration.py | 75 +++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 86087bfc..c9cff4db 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -450,19 +450,26 @@ class Config: def get_db_parameters(self, name = None): if name == None: name = 'fpdb' db = {} - try: - db['db-databaseName'] = name - db['db-host'] = self.supported_databases[name].db_ip - db['db-user'] = self.supported_databases[name].db_user - db['db-password'] = self.supported_databases[name].db_pass - db['db-server'] = self.supported_databases[name].db_server - if string.lower(self.supported_databases[name].db_server) == 'mysql': - db['db-backend'] = 2 - elif string.lower(self.supported_databases[name].db_server) == 'postgresql': - db['db-backend'] = 3 - else: db['db-backend'] = None # this is big trouble - except: - pass + try: db['db-databaseName'] = name + except: pass + + try: db['db-host'] = self.supported_databases[name].db_ip + except: pass + + try: db['db-user'] = self.supported_databases[name].db_user + except: pass + + try: db['db-password'] = self.supported_databases[name].db_pass + except: pass + + try: db['db-server'] = self.supported_databases[name].db_server + except: pass + + if string.lower(self.supported_databases[name].db_server) == 'mysql': + db['db-backend'] = 2 + elif string.lower(self.supported_databases[name].db_server) == 'postgresql': + db['db-backend'] = 3 + else: db['db-backend'] = None # this is big trouble return db def set_db_parameters(self, db_name = 'fpdb', db_ip = None, db_user = None, @@ -484,30 +491,32 @@ class Config: def get_tv_parameters(self): tv = {} - try: - tv['combinedStealFold'] = self.tv.combinedStealFold - tv['combined2B3B'] = self.tv.combined2B3B - tv['combinedPostflop'] = self.tv.combinedPostflop - except: # Default tv parameters - tv['combinedStealFold'] = True - tv['combined2B3B'] = True - tv['combinedPostflop'] = True + try: tv['combinedStealFold'] = self.tv.combinedStealFold + except: tv['combinedStealFold'] = True + + try: tv['combined2B3B'] = self.tv.combined2B3B + except: tv['combined2B3B'] = True + + try: tv['combinedPostflop'] = self.tv.combinedPostflop + except: tv['combinedPostflop'] = True return tv def get_import_parameters(self): imp = {} - try: - imp['callFpdbHud'] = self.imp.callFpdbHud - imp['interval'] = self.imp.interval - imp['hhArchiveBase'] = self.imp.hhArchiveBase - imp['saveActions'] = self.imp.saveActions - imp['fastStoreHudCache'] = self.imp.fastStoreHudCache - except: # Default params - imp['callFpdbHud'] = True - imp['interval'] = 10 - imp['hhArchiveBase'] = "~/.fpdb/HandHistories/" - imp['saveActions'] = True - imp['fastStoreHudCache'] = True + try: imp['callFpdbHud'] = self.imp.callFpdbHud + except: imp['callFpdbHud'] = True + + try: imp['interval'] = self.imp.interval + except: imp['interval'] = 10 + + try: imp['hhArchiveBase'] = self.imp.hhArchiveBase + except: imp['hhArchiveBase'] = "~/.fpdb/HandHistories/" + + try: imp['saveActions'] = self.imp.saveActions + except: imp['saveActions'] = True + + try: imp['fastStoreHudCache'] = self.imp.fastStoreHudCache + except: imp['fastStoreHudCache'] = True return imp def get_default_paths(self, site = "PokerStars"): From 48c2c36de634b2e18b36d878076f5506bd7c150d Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 17 Mar 2009 11:18:55 -0400 Subject: [PATCH 09/13] Put index dropping back in for postgres. --- pyfpdb/fpdb_simple.py | 73 +++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 6ac28bd1..2677d11b 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -157,15 +157,12 @@ def prepareBulkImport(fdb): pass elif fdb.backend == PGSQL: # DON'T FORGET TO RECREATE THEM!! - print "Index dropping disabled for postgresql." -# 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 " + fk['fktab'] + " drop constraint " \ -# + fk['fktab'] + '_' + fk['fkcol'] + '_fkey' -# except: -# pass + print "dropping pg fk", fk['fktab'], fk['fkcol'] + try: + fdb.cursor.execute("alter table " + fk['fktab'] + " drop constraint " + + fk['fktab'] + '_' + fk['fkcol'] + '_fkey') + except: + pass else: print "Only MySQL and Postgres supported so far" return -1 @@ -181,15 +178,14 @@ def prepareBulkImport(fdb): elif fdb.backend == PGSQL: # DON'T FORGET TO RECREATE THEM!! print "Index dropping disabled for postgresql." -# print "dropping pg index ", idx['tab'], idx['col'] -# # mod to use tab_col for index name? -# try: -# pass -# 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'] -# except: -# pass + 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'] + except: + pass else: print "Only MySQL and Postgres supported so far" return -1 @@ -228,19 +224,14 @@ def afterBulkImport(fdb): except: pass elif fdb.backend == PGSQL: - pass -# print "creating fk ", fk['fktab'], fk['fkcol'], "->", fk['rtab'], fk['rcol'] -# try: -# print "alter table " + fk['fktab'] + " add constraint " \ -# + fk['fktab'] + '_' + fk['fkcol'] + '_fkey' \ -# + " foreign key (" + fk['fkcol'] \ -# + ") references " + fk['rtab'] + "(" + fk['rcol'] + ")" -# fdb.cursor.execute("alter table " + fk['fktab'] + " add constraint " -# + fk['fktab'] + '_' + fk['fkcol'] + '_fkey' -# + " foreign key (" + fk['fkcol'] -# + ") references " + fk['rtab'] + "(" + fk['rcol'] + ")") -# except: -# pass + print "creating fk ", fk['fktab'], fk['fkcol'], "->", fk['rtab'], fk['rcol'] + try: + fdb.cursor.execute("alter table " + fk['fktab'] + " add constraint " + + fk['fktab'] + '_' + fk['fkcol'] + '_fkey' + + " foreign key (" + fk['fkcol'] + + ") references " + fk['rtab'] + "(" + fk['rcol'] + ")") + except: + pass else: print "Only MySQL and Postgres supported so far" return -1 @@ -255,16 +246,16 @@ def afterBulkImport(fdb): except: pass elif fdb.backend == PGSQL: - pass -# # mod to use tab_col for index name? -# print "creating pg index ", idx['tab'], idx['col'] -# try: -# print "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col']) -# fdb.cursor.execute( "create index %s_%s_idx on %s(%s)" -# % (idx['tab'], idx['col'], idx['tab'], idx['col']) ) -# except: -# print " ERROR! :-(" -# pass +# pass + # mod to use tab_col for index name? + print "creating pg index ", idx['tab'], idx['col'] + try: + print "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col']) + fdb.cursor.execute( "create index %s_%s_idx on %s(%s)" + % (idx['tab'], idx['col'], idx['tab'], idx['col']) ) + except: + print " ERROR! :-(" + pass else: print "Only MySQL and Postgres supported so far" return -1 From e485a9c035668861fe8a058d99be6af6f194ed91 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 18 Mar 2009 11:34:43 -0400 Subject: [PATCH 10/13] Fix silly cut/paste problem. --- pyfpdb/Configuration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index c9cff4db..05e29a62 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -212,7 +212,7 @@ class Import: if node.hasAttribute("fastStoreHudCache"): self.fastStoreHudCache = node.getAttribute("fastStoreHudCache") else: - self.saveActions = False + self.fastStoreHudCache = False def __str__(self): return " interval = %s\n callFpdbHud = %s\n hhArchiveBase = %s\n saveActions = %s\n fastStoreHudCache = %s\n" \ From e67f715f27a07c23187906daad851fdf31eeed9c Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 18 Mar 2009 11:37:36 -0400 Subject: [PATCH 11/13] Another silly screw up. --- pyfpdb/Configuration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 05e29a62..c113f9db 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -208,7 +208,7 @@ class Import: if node.hasAttribute("saveActions"): self.saveActions = node.getAttribute("saveActions") else: - self.saveActions = False + self.saveActions = True if node.hasAttribute("fastStoreHudCache"): self.fastStoreHudCache = node.getAttribute("fastStoreHudCache") else: From 8009281e5a28ed727b95e67532e3cd29663bdfcf Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 18 Mar 2009 12:32:34 -0400 Subject: [PATCH 12/13] More fixing of import options. --- pyfpdb/Configuration.py | 11 +++++++++-- pyfpdb/fpdb_save_to_db.py | 40 ++++++++------------------------------- 2 files changed, 17 insertions(+), 34 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index c113f9db..81645694 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -32,6 +32,13 @@ import shutil import xml.dom.minidom from xml.dom.minidom import Node +def fix_tf(x): + if x == "1" or x == 1 or string.lower(x) == "true" or string.lower(x) == "t": + return True + if x == "0" or x == 0 or string.lower(x) == "false" or string.lower(x) == "f": + return False + return False + class Layout: def __init__(self, node): @@ -206,11 +213,11 @@ class Import: self.callFpdbHud = node.getAttribute("callFpdbHud") self.hhArchiveBase = node.getAttribute("hhArchiveBase") if node.hasAttribute("saveActions"): - self.saveActions = node.getAttribute("saveActions") + self.saveActions = fix_tf(node.getAttribute("saveActions")) else: self.saveActions = True if node.hasAttribute("fastStoreHudCache"): - self.fastStoreHudCache = node.getAttribute("fastStoreHudCache") + self.fastStoreHudCache = fix_tf(node.getAttribute("fastStoreHudCache")) else: self.fastStoreHudCache = False diff --git a/pyfpdb/fpdb_save_to_db.py b/pyfpdb/fpdb_save_to_db.py index b215f7ee..68c11833 100644 --- a/pyfpdb/fpdb_save_to_db.py +++ b/pyfpdb/fpdb_save_to_db.py @@ -40,14 +40,8 @@ def ring_stud(config, backend, db, cursor, base, category, site_hand_no, gametyp ,seatNos): import_options = config.get_import_parameters() - if import_options['saveActions'] == 'True': - saveActions = True - else: - saveActions = False - if import_options['fastStoreHudCache'] == 'True': - fastStoreHudCache = True - else: - fastStoreHudCache = False + saveActions = import_options['saveActions'] + fastStoreHudCache = import_options['fastStoreHudCache'] fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) @@ -74,14 +68,8 @@ 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() - if import_options['saveActions'] == 'True': - saveActions = True - else: - saveActions = False - if import_options['fastStoreHudCache'] == 'True': - fastStoreHudCache = True - else: - fastStoreHudCache = False + saveActions = import_options['saveActions'] + fastStoreHudCache = import_options['fastStoreHudCache'] t0 = time() fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) @@ -121,14 +109,8 @@ def tourney_holdem_omaha(config, backend, db, cursor, base, category, siteTourne """stores a tourney holdem/omaha hand into the database""" import_options = config.get_import_parameters() - if import_options['saveActions'] == 'True': - saveActions = True - else: - saveActions = False - if import_options['fastStoreHudCache'] == 'True': - fastStoreHudCache = True - else: - fastStoreHudCache = False + saveActions = import_options['saveActions'] + fastStoreHudCache = import_options['fastStoreHudCache'] fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits) fpdb_simple.fill_board_cards(board_values, board_suits) @@ -164,14 +146,8 @@ def tourney_stud(config, backend, db, cursor, base, category, siteTourneyNo, buy #stores a tourney stud/razz hand into the database import_options = config.get_import_parameters() - if import_options['saveActions'] == 'True': - saveActions = True - else: - saveActions = False - if import_options['fastStoreHudCache'] == 'True': - fastStoreHudCache = True - else: - fastStoreHudCache = False + saveActions = import_options['saveActions'] + fastStoreHudCache = import_options['fastStoreHudCache'] fpdb_simple.fillCardArrays(len(names), base, category, cardValues, cardSuits) From 530462cc72cf4070a8cc0ab4242cc62c900fdf78 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 18 Mar 2009 21:05:29 -0400 Subject: [PATCH 13/13] Fix for too large mucked windows on Windows. --- pyfpdb/Mucked.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index faf0fe3a..1d7e9597 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -373,6 +373,7 @@ class Flop_Mucked(Aux_Window): x = x + int(self.params['card_wd']) 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].move(self.positions[i][0], self.positions[i][1]) # here is where I move back self.displayed_cards = True