From 3c9f5537ea155fa81ffaa421dabffbd10abd690e Mon Sep 17 00:00:00 2001 From: eblade Date: Wed, 25 Feb 2009 12:40:39 -0500 Subject: [PATCH 1/6] import should stop erroring out and crashing if a file it wanted to read has been deleted --- pyfpdb/fpdb_import.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index aeb1e027..ca9167e8 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -235,8 +235,9 @@ class Importer: if (file=="stdin"): inputFile=sys.stdin else: - inputFile=open(file, "rU") - try: loc = self.pos_in_file[file] + try: + inputFile=open(file, "rU") + loc = self.pos_in_file[file] except: pass # Read input file into class and close file From 7ebf27c07e2716d81d978597b546be021829674f Mon Sep 17 00:00:00 2001 From: eblade Date: Wed, 25 Feb 2009 15:25:58 -0500 Subject: [PATCH 2/6] add site config option "use_frames", set to "True" to get frames --- pyfpdb/Configuration.py | 4 ++++ pyfpdb/EverleafToFpdb.py | 7 +++++++ pyfpdb/Hud.py | 20 +++++++++++++------- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index a9a884a7..fb182f4b 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -62,6 +62,7 @@ class Site: self.aux_window = node.getAttribute("aux_window") self.font = node.getAttribute("font") self.font_size = node.getAttribute("font_size") + self.use_frames = node.getAttribute("use_frames") self.layout = {} for layout_node in node.getElementsByTagName('layout'): @@ -465,6 +466,9 @@ class Config: paths['hud-defaultPath'] = "default" paths['bulkImport-defaultPath'] = "default" return paths + + def get_frames(self, site = "PokerStars"): + return self.supported_sites[site].use_frames == "True" def get_default_colors(self, site = "PokerStars"): colors = {} diff --git a/pyfpdb/EverleafToFpdb.py b/pyfpdb/EverleafToFpdb.py index 33ae0cd3..a97e2bde 100755 --- a/pyfpdb/EverleafToFpdb.py +++ b/pyfpdb/EverleafToFpdb.py @@ -65,6 +65,13 @@ class Everleaf(HandHistoryConverter): # Blinds $0.50/$1 PL Omaha - 2008/12/07 - 21:59:48 # Blinds $0.05/$0.10 NL Hold'em - 2009/02/21 - 11:21:57 # $0.25/$0.50 7 Card Stud - 2008/12/05 - 21:43:59 + + # Tourney: + # Everleaf Gaming Game #75065769 + # ***** Hand history for game #75065769 ***** + # Blinds 10/20 NL Hold'em - 2009/02/25 - 17:30:32 + # Table 2 + structure = "" # nl, pl, cn, cp, fl game = "" diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 17497d90..f77b7318 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -285,7 +285,7 @@ class Hud: self.stat_windows[stat_dict[s]['seat']].player_id = 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.create(hand, config, stat_dict) self.stat_windows[stat_dict[s]['seat']].player_id = stat_dict[s]['player_id'] for r in range(0, config.supported_games[self.poker_game].rows): @@ -365,6 +365,7 @@ class Stat_Window: self.y = y + table.y # x and y are the location relative to table.x & y self.player_id = player_id # looks like this isn't used ;) self.sb_click = 0 # used to figure out button clicks + self.useframes = parent.config.get_frames(parent.site) self.window = gtk.Window() self.window.set_decorated(0) @@ -382,23 +383,28 @@ class Stat_Window: self.frame = [] self.label = [] for r in range(self.game.rows): - self.frame.append([]) + if self.useframes: + self.frame.append([]) self.e_box.append([]) self.label.append([]) for c in range(self.game.cols): - self.frame[r].append( gtk.Frame() ) + if self.useframes: + self.frame[r].append( gtk.Frame() ) self.e_box[r].append( gtk.EventBox() ) self.e_box[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) self.e_box[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor) Stats.do_tip(self.e_box[r][c], 'stuff') -# self.grid.attach(self.e_box[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0) - self.grid.attach(self.frame[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0) - self.frame[r][c].add(self.e_box[r][c]) + if self.useframes: + self.grid.attach(self.frame[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0) + self.frame[r][c].add(self.e_box[r][c]) + else: + self.grid.attach(self.e_box[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0) self.label[r].append( gtk.Label('xxx') ) - self.frame[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) + if self.useframes: + self.frame[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) self.label[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) self.label[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor) From 560cb1a543b481415764b88448210b7d5b0562ac Mon Sep 17 00:00:00 2001 From: eblade Date: Wed, 25 Feb 2009 22:44:03 -0500 Subject: [PATCH 3/6] fpdb_import runUpdated() will now remove files that were found to be newly missing on it's most recent pass from it's list of files to check --- pyfpdb/fpdb_import.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index ca9167e8..aa40b218 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -61,6 +61,7 @@ class Importer: self.filelist = {} self.dirlist = {} self.addToDirList = {} + self.removeFromFileList = {} # to remove deleted files self.monitor = False self.updated = {} #Time last import was run {file:mtime} self.lines = None @@ -187,8 +188,12 @@ class Importer: for dir in self.addToDirList: self.addImportDirectory(dir, True, self.addToDirList[dir][0], self.addToDirList[dir][1]) + + for file in self.removeFromFileList: + del self.filelist[file] self.addToDirList = {} + self.removeFromFileList = {} # This is now an internal function that should not be called directly. def import_file_dict(self, file, site, filter): @@ -235,10 +240,15 @@ class Importer: if (file=="stdin"): inputFile=sys.stdin else: + if os.path.exists(file): + inputFile = open(file, "rU") + else: + self.removeFromFileList['file'] = True + return try: - inputFile=open(file, "rU") loc = self.pos_in_file[file] - except: pass + except: + pass # Read input file into class and close file inputFile.seek(loc) From 9066cf9fc6ad9330730970be976f086194a68992 Mon Sep 17 00:00:00 2001 From: eblade Date: Wed, 25 Feb 2009 22:47:22 -0500 Subject: [PATCH 4/6] return appropriate tuple from import_fpdb_file on file error --- 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 aa40b218..16435b06 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -244,7 +244,7 @@ class Importer: inputFile = open(file, "rU") else: self.removeFromFileList['file'] = True - return + return (0, 0, 0, 1, 0) try: loc = self.pos_in_file[file] except: From c7541d9f14d9a7f2fc007b168a24791da715dc05 Mon Sep 17 00:00:00 2001 From: eblade Date: Wed, 25 Feb 2009 23:17:36 -0500 Subject: [PATCH 5/6] return appropriate tuple from import_fpdb_file on file error --- pyfpdb/fpdb_import.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index aa40b218..980b1bae 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -190,7 +190,8 @@ class Importer: self.addImportDirectory(dir, True, self.addToDirList[dir][0], self.addToDirList[dir][1]) for file in self.removeFromFileList: - del self.filelist[file] + if file in self.filelist: + del self.filelist[file] self.addToDirList = {} self.removeFromFileList = {} @@ -243,8 +244,8 @@ class Importer: if os.path.exists(file): inputFile = open(file, "rU") else: - self.removeFromFileList['file'] = True - return + self.removeFromFileList[file] = True + return (0, 0, 0, 1, 0) try: loc = self.pos_in_file[file] except: From 9557117a16b78b3be4297760bbb1804f32d7f9a6 Mon Sep 17 00:00:00 2001 From: eblade Date: Thu, 26 Feb 2009 09:27:59 -0500 Subject: [PATCH 6/6] add "totalprofit" stat --- pyfpdb/Stats.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyfpdb/Stats.py b/pyfpdb/Stats.py index 0870c73e..cad3af88 100644 --- a/pyfpdb/Stats.py +++ b/pyfpdb/Stats.py @@ -70,6 +70,13 @@ def do_stat(stat_dict, player = 24, stat = 'vpip'): ########################################### # functions that return individual stats +def totalprofit(stat_dict, player): + """ Total Profit.""" + if stat_dict[player]['net'] != 0: + stat = float(stat_dict[player]['net']) / 100 + return (stat, '$%.2f' % stat, 'tp=$%.2f' % stat, 'totalprofit=$%.2f' % stat, str(stat), 'Total Profit') + return ('0', '0', '0', '0', 'Total Profit') + def playername(stat_dict, player): """ Player Name.""" return (stat_dict[player]['screen_name'],