diff --git a/docs/readme.txt b/docs/readme.txt index 03e071d3..e3dbac23 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -1,5 +1,5 @@ README.txt -updated 26 March 2009, REB +updated 22 February 2010, REB fpdb - Free Poker Database @@ -29,7 +29,7 @@ fpdb supports: Omaha (incl Hi/low) 7 Card Stud (incl Hi/low) Razz - Draw support is under development + Triple Draw and Badugi Mixed Games -- HUD under development Operating Systems: @@ -38,23 +38,38 @@ fpdb supports: Mac OS/X -- no support for HUD Databases: + SQLite configured by default MySQL PostgreSQL - SQLite under development Downloads: Releases: http://sourceforge.net/project/showfiles.php?group_id=226872 Development code via git: http://www.assembla.com/spaces/free_poker_tools/trac_git_tool Developers: - At least 7 people have contributed code or patches. Others are welcome. + At least 10 people have contributed code or patches. Others are welcome. +Source Code: + If you received fpdb as the Windows compressed exe, then you did not +receive souce code for fpdb or the included libraries. If you wish, you can +obtain the source code here: + + fpdb: see Downloads, above. + python: http://python.org/ + gtk: http://www.gtk.org/download.html + pygtk: http://www.pygtk.org/downloads.html + psycopg2: http://initd.org/pub/software/psycopg/ + mysqldb: http://sourceforge.net/projects/mysql-python/files/ + sqlalchemy: http://www.sqlalchemy.org/download.html + numpy: http://www.scipy.org/Download + matplotlib: http://sourceforge.net/projects/matplotlib/files/ + License ======= Trademarks of third parties have been used under Fair Use or similar laws. Copyright 2008 Steffen Jobbagy-Felso -Copyright 2009 Ray E. Barker +Copyright 2009,2010 Ray E. Barker Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 as published by the Free Software Foundation; with diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py index 07c96a04..d0f81a1b 100755 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -414,6 +414,7 @@ class Import: self.hhArchiveBase = node.getAttribute("hhArchiveBase") self.saveActions = string_to_bool(node.getAttribute("saveActions"), default=True) self.fastStoreHudCache = string_to_bool(node.getAttribute("fastStoreHudCache"), default=False) + self.saveStarsHH = string_to_bool(node.getAttribute("saveStarsHH"), default=False) def __str__(self): return " interval = %s\n callFpdbHud = %s\n hhArchiveBase = %s\n saveActions = %s\n fastStoreHudCache = %s\n" \ @@ -469,7 +470,8 @@ class Config: self.file = file self.dir_self = get_exec_path() - self.dir_config = os.path.dirname(self.file) +# self.dir_config = os.path.dirname(self.file) + self.dir_config = get_default_config_path() self.dir_log = os.path.join(self.dir_config, 'log') self.dir_database = os.path.join(self.dir_config, 'database') self.log_file = os.path.join(self.dir_log, 'fpdb-log.txt') @@ -822,8 +824,12 @@ class Config: try: imp['saveActions'] = self.imp.saveActions except: imp['saveActions'] = True + try: imp['saveStarsHH'] = self.imp.saveStarsHH + except: imp['saveStarsHH'] = False + try: imp['fastStoreHudCache'] = self.imp.fastStoreHudCache except: imp['fastStoreHudCache'] = True + return imp def get_default_paths(self, site = None): diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index 2ea223f4..92f888d8 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -61,7 +61,7 @@ import Hud # get config and set up logger -c = Configuration.Config(file=options.config) +c = Configuration.Config(file=options.config, dbname=options.dbname) log = Configuration.get_logger("logging.conf", "hud", log_dir=c.dir_log, log_file='HUD-log.txt') @@ -78,14 +78,14 @@ class HUD_main(object): try: 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" - log.info("Note: error output is being diverted to:"+fileName) - log.info("Any major error will be reported there _only_.") - errorFile = open(fileName, 'w', 0) - sys.stderr = errorFile - sys.stderr.write("HUD_main: starting ...\n") + 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" + log.info("Note: error output is being diverted to:"+fileName) + log.info("Any major error will be reported there _only_.") + errorFile = open(fileName, 'w', 0) + sys.stderr = errorFile + sys.stderr.write("HUD_main: starting ...\n") self.hud_dict = {} self.hud_params = self.config.get_hud_ui_parameters() @@ -237,7 +237,7 @@ class HUD_main(object): try: (table_name, max, poker_game, type, site_id, site_name, num_seats, tour_number, tab_number) = \ self.db_connection.get_table_info(new_hand_id) - except Exception, err: + except Exception: log.error("db error: skipping %s" % new_hand_id) continue t1 = time.time() diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 4bf7564d..2053eba9 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -69,6 +69,7 @@ out_path (default '-' = sys.stdout) follow : whether to tail -f the input""" self.config = config + self.import_parameters = self.config.get_import_parameters() #log = Configuration.get_logger("logging.conf", "parser", log_dir=self.config.dir_log) log.info("HandHistory init - %s subclass, in_path '%s'; out_path '%s'" % (self.sitename, in_path, out_path) ) @@ -87,12 +88,8 @@ follow : whether to tail -f the input""" if in_path == '-': self.in_fh = sys.stdin + self.out_fh = get_out_fh(out_path, self.import_parameters) - if out_path == '-': - self.out_fh = sys.stdout - else: - # TODO: out_path should be sanity checked. - self.out_fh = sys.stdout self.follow = follow self.compiledPlayers = set() self.maxseats = 10 @@ -446,8 +443,8 @@ or None if we fail to get the info """ def guessMaxSeats(self, hand): """Return a guess at maxseats when not specified in HH.""" # if some other code prior to this has already set it, return it - if maxseats > 1 and maxseats < 11: - return maxseats + if self.maxseats > 1 and self.maxseats < 11: + return self.maxseats mo = self.maxOccSeat(hand) if mo == 10: return 10 #that was easy @@ -515,3 +512,23 @@ def getSiteHhc(config, sitename): hhcName = config.supported_sites[sitename].converter hhcModule = __import__(hhcName) return getattr(hhcModule, hhcName[:-6]) + +def get_out_fh(out_path, parameters): + if out_path == '-': + return(sys.stdout) + elif parameters['saveStarsHH']: + out_dir = os.path.dirname(out_path) + if not os.path.isdir(out_dir) and out_dir != '': + try: + os.makedirs(out_dir) + except: # we get a WindowsError here in Windows.. pretty sure something else for Linux :D + log.error("Unable to create output directory %s for HHC!" % out_dir) + print "*** ERROR: UNABLE TO CREATE OUTPUT DIRECTORY", out_dir + else: + log.info("Created directory '%s'" % out_dir) + try: + return(codecs.open(out_path, 'w', 'utf8')) + except: + log.error("out_path %s couldn't be opened" % (out_path)) + else: + return(sys.stdout) diff --git a/pyfpdb/XTables.py b/pyfpdb/XTables.py index a14debc1..28737002 100644 --- a/pyfpdb/XTables.py +++ b/pyfpdb/XTables.py @@ -89,7 +89,6 @@ class Table(Table_Window): # break if window_number is None: - print "Window %s not found. Skipping." % search_string return None # my_geo = self.window.get_geometry() diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 7e81d1e6..768795ab 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -1025,23 +1025,24 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") return response def validate_config(self): - hhbase = self.config.get_import_parameters().get("hhArchiveBase") - hhbase = os.path.expanduser(hhbase) - #hhdir = os.path.join(hhbase,site) - hhdir = hhbase - if not os.path.isdir(hhdir): - diapath = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=(gtk.BUTTONS_YES_NO), message_format="Setup hh dir") - diastring = "WARNING: Unable to find output hh directory %s\n\n Press YES to create this directory, or NO to select a new one." % hhdir - diapath.format_secondary_text(diastring) - response = diapath.run() - diapath.destroy() - if response == gtk.RESPONSE_YES: - try: - os.makedirs(hhdir) - except: - self.warning_box("WARNING: Unable to create hand output directory. Importing is not likely to work until this is fixed.") - elif response == gtk.RESPONSE_NO: - self.select_hhArchiveBase() + if self.config.get_import_parameters().get('saveStarsHH'): + hhbase = self.config.get_import_parameters().get("hhArchiveBase") + hhbase = os.path.expanduser(hhbase) + #hhdir = os.path.join(hhbase,site) + hhdir = hhbase + if not os.path.isdir(hhdir): + diapath = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=(gtk.BUTTONS_YES_NO), message_format="Setup hh dir") + diastring = "WARNING: Unable to find output hh directory %s\n\n Press YES to create this directory, or NO to select a new one." % hhdir + diapath.format_secondary_text(diastring) + response = diapath.run() + diapath.destroy() + if response == gtk.RESPONSE_YES: + try: + os.makedirs(hhdir) + except: + self.warning_box("WARNING: Unable to create hand output directory. Importing is not likely to work until this is fixed.") + elif response == gtk.RESPONSE_NO: + self.select_hhArchiveBase() def select_hhArchiveBase(self, widget=None): fc = gtk.FileChooserDialog(title="Select HH Output Directory", parent=None, action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, buttons=(gtk.STOCK_OPEN,gtk.RESPONSE_OK), backend=None)