From fece7c914713c43c0a6c73c8dedd1381b4aa9d0f Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Tue, 2 Feb 2010 21:53:03 +0000 Subject: [PATCH 1/5] move fpdb-error-log and HUD-error to APPDATA, renamed as fpdb-errors.txt and HUD-errors.txt to be consistent --- pyfpdb/HUD_main.py | 11 ++++++++--- pyfpdb/fpdb.py | 15 ++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index f7979552..bae58825 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -35,9 +35,6 @@ import traceback (options, argv) = Options.fpdb_options() -if not options.errorsToConsole: - print "Note: error output is being logged. Any major error will be reported there _only_." - import thread import time import string @@ -79,6 +76,14 @@ class HUD_main(object): log = Configuration.get_logger("logging.conf", "hud", log_dir=self.config.dir_log) log.info("HUD_main starting") log.info("Using db name = %s" % (db_name)) + + if not options.errorsToConsole: + fileName = os.path.join(self.config.dir_log, 'HUD-errors.txt') + print "Note: error output is being diverted to\n"+fileName \ + + "\nAny major error will be reported there _only_.\n" + errorFile = open(fileName, 'w', 0) + sys.stderr = errorFile + self.hud_dict = {} self.hud_params = self.config.get_hud_ui_parameters() diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 5bef3503..d5e0350d 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -53,7 +53,7 @@ if os.name == 'nt': raw_input("Press ENTER to continue.") exit() -print "Python " + sys.version[0:3] + '...\n' +print "Python " + sys.version[0:3] + '...' import traceback import threading @@ -62,12 +62,6 @@ import string cl_options = string.join(sys.argv[1:]) (options, argv) = Options.fpdb_options() -if not options.errorsToConsole: - print "Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_." - errorFile = open('fpdb-error-log.txt', 'w', 0) - sys.stderr = errorFile - -#import logging import logging, logging.config try: @@ -910,6 +904,13 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") self.window.show() self.load_profile() + if not options.errorsToConsole: + fileName = os.path.join(self.config.dir_log, 'fpdb-errors.txt') + print "\nNote: error output is being diverted to fpdb-errors.txt and HUD-errors.txt in\n" \ + + self.config.dir_log + "Any major error will be reported there _only_.\n" + errorFile = open(fileName, 'w', 0) + sys.stderr = errorFile + self.statusIcon = gtk.StatusIcon() if os.path.exists(os.path.join(sys.path[0], '../gfx/fpdb-cards.png')): self.statusIcon.set_from_file(os.path.join(sys.path[0], '../gfx/fpdb-cards.png')) From e3679a99fb0f7221798c3415aa98f0f819f8d6ac Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Wed, 3 Feb 2010 00:48:45 +0000 Subject: [PATCH 2/5] fix steal calcs --- pyfpdb/DerivedStats.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py index 88bb6407..23f1f99c 100644 --- a/pyfpdb/DerivedStats.py +++ b/pyfpdb/DerivedStats.py @@ -56,7 +56,6 @@ class DerivedStats(): self.handsplayers[player[1]]['stealAttemptChance'] = False self.handsplayers[player[1]]['stealAttempted'] = False self.handsplayers[player[1]]['foldBbToStealChance'] = False - self.handsplayers[player[1]]['foldBbToStealChance'] = False self.handsplayers[player[1]]['foldSbToStealChance'] = False self.handsplayers[player[1]]['foldedSbToSteal'] = False self.handsplayers[player[1]]['foldedBbToSteal'] = False @@ -281,33 +280,37 @@ class DerivedStats(): def calcSteals(self, hand): """Fills stealAttempt(Chance|ed, fold(Bb|Sb)ToSteal(Chance|) - Steal attemp - open raise on positions 2 1 0 S - i.e. MP3, CO, BU, SB + Steal attempt - open raise on positions 1 0 S - i.e. MP3, CO, BU, SB Fold to steal - folding blind after steal attemp wo any other callers or raisers """ - steal_attemp = False - steal_positions = ('2', '1', '0', 'S') + steal_attempt = False + steal_positions = (1, 0, 'S') if hand.gametype['base'] == 'stud': - steal_positions = ('2', '1', '0') + steal_positions = (2, 1, 0) for action in hand.actions[hand.actionStreets[1]]: pname, act = action[0], action[1] - #print action[0], hp.position, steal_attemp, act - if self.handsplayers[pname]['position'] == 'B': + posn = self.handsplayers[pname]['position'] + #print "\naction:", action[0], posn, type(posn), steal_attempt, act + if posn == 'B': #NOTE: Stud games will never hit this section - self.handsplayers[pname]['foldBbToStealChance'] = steal_attemp - self.handsplayers[pname]['foldBbToSteal'] = self.handsplayers[pname]['foldBbToStealChance'] and act == 'folds' + self.handsplayers[pname]['foldBbToStealChance'] = steal_attempt + self.handsplayers[pname]['foldedBbToSteal'] = steal_attempt and act == 'folds' break - elif self.handsplayers[pname]['position'] == 'S': - self.handsplayers[pname]['foldSbToStealChance'] = steal_attemp - self.handsplayers[pname]['foldSbToSteal'] = self.handsplayers[pname]['foldSbToStealChance'] and act == 'folds' + elif posn == 'S': + self.handsplayers[pname]['foldSbToStealChance'] = steal_attempt + self.handsplayers[pname]['foldedSbToSteal'] = steal_attempt and act == 'folds' - if steal_attemp and act != 'folds': + if steal_attempt and act != 'folds': break - if self.handsplayers[pname]['position'] in steal_positions and not steal_attemp: + if posn in steal_positions and not steal_attempt: self.handsplayers[pname]['stealAttemptChance'] = True if act in ('bets', 'raises'): self.handsplayers[pname]['stealAttempted'] = True - steal_attemp = True + steal_attempt = True + + if posn not in steal_positions and act != 'folds': + break def calc34BetStreet0(self, hand): """Fills street0_(3|4)B(Chance|Done), other(3|4)BStreet0""" From 864454f31c0408e9d24ff2a61c26a4077622dc74 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Wed, 3 Feb 2010 01:03:36 +0000 Subject: [PATCH 3/5] change 2 commits to 1, may help sqlite stop locking up --- pyfpdb/fpdb_import.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 8b3f71cd..95ffd525 100755 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -451,14 +451,14 @@ class Importer: to_hud.append(hand.dbid_hands) else: # TODO: Treat empty as an error, or just ignore? log.error("Hand processed but empty") - self.database.commit() + # Call hudcache update if not in bulk import mode # FIXME: Need to test for bulk import that isn't rebuilding the cache if self.callHud: for hand in handlist: if hand is not None: hand.updateHudCache(self.database) - self.database.commit() + self.database.commit() #pipe the Hands.id out to the HUD for hid in to_hud: From 33455cb1acacd092ac2ae955e31d360c24f42409 Mon Sep 17 00:00:00 2001 From: Worros Date: Wed, 3 Feb 2010 21:52:44 +0800 Subject: [PATCH 4/5] PokerStars: Fix tablename regex to allow a # Occasionally Stars throws up a cash table that looks like PokerStars Game #22920951206: Triple Draw 2-7 Lowball Limit ($0.10/$0.20) - 2008/12/14 17:44:00 ET Table 'T #252691988' 6-max Seat #2 is the button a # was previously excluded from the regex. --- pyfpdb/PokerStarsToFpdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/PokerStarsToFpdb.py b/pyfpdb/PokerStarsToFpdb.py index c8bfea70..c2a92881 100755 --- a/pyfpdb/PokerStarsToFpdb.py +++ b/pyfpdb/PokerStarsToFpdb.py @@ -69,7 +69,7 @@ class PokerStars(HandHistoryConverter): re.MULTILINE|re.VERBOSE) re_HandInfo = re.compile(""" - ^Table\s\'(?P[-\ a-zA-Z\d]+)\'\s + ^Table\s\'(?P
[-\ \#a-zA-Z\d]+)\'\s ((?P\d+)-max\s)? (?P\(Play\sMoney\)\s)? (Seat\s\#(?P