Merge branch 'master' of git://git.assembla.com/free_poker_tools.git

This commit is contained in:
Gerko de Roo 2010-02-26 18:20:04 +01:00
commit 9b93cd42e3
6 changed files with 79 additions and 41 deletions

View File

@ -1,5 +1,5 @@
README.txt README.txt
updated 26 March 2009, REB updated 22 February 2010, REB
fpdb - Free Poker Database fpdb - Free Poker Database
@ -29,7 +29,7 @@ fpdb supports:
Omaha (incl Hi/low) Omaha (incl Hi/low)
7 Card Stud (incl Hi/low) 7 Card Stud (incl Hi/low)
Razz Razz
Draw support is under development Triple Draw and Badugi
Mixed Games -- HUD under development Mixed Games -- HUD under development
Operating Systems: Operating Systems:
@ -38,23 +38,38 @@ fpdb supports:
Mac OS/X -- no support for HUD Mac OS/X -- no support for HUD
Databases: Databases:
SQLite configured by default
MySQL MySQL
PostgreSQL PostgreSQL
SQLite under development
Downloads: Downloads:
Releases: http://sourceforge.net/project/showfiles.php?group_id=226872 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 Development code via git: http://www.assembla.com/spaces/free_poker_tools/trac_git_tool
Developers: 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 License
======= =======
Trademarks of third parties have been used under Fair Use or similar laws. Trademarks of third parties have been used under Fair Use or similar laws.
Copyright 2008 Steffen Jobbagy-Felso 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 Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License, document under the terms of the GNU Free Documentation License,
Version 1.2 as published by the Free Software Foundation; with Version 1.2 as published by the Free Software Foundation; with

View File

@ -414,6 +414,7 @@ class Import:
self.hhArchiveBase = node.getAttribute("hhArchiveBase") self.hhArchiveBase = node.getAttribute("hhArchiveBase")
self.saveActions = string_to_bool(node.getAttribute("saveActions"), default=True) self.saveActions = string_to_bool(node.getAttribute("saveActions"), default=True)
self.fastStoreHudCache = string_to_bool(node.getAttribute("fastStoreHudCache"), default=False) self.fastStoreHudCache = string_to_bool(node.getAttribute("fastStoreHudCache"), default=False)
self.saveStarsHH = string_to_bool(node.getAttribute("saveStarsHH"), default=False)
def __str__(self): def __str__(self):
return " interval = %s\n callFpdbHud = %s\n hhArchiveBase = %s\n saveActions = %s\n fastStoreHudCache = %s\n" \ 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.file = file
self.dir_self = get_exec_path() 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_log = os.path.join(self.dir_config, 'log')
self.dir_database = os.path.join(self.dir_config, 'database') self.dir_database = os.path.join(self.dir_config, 'database')
self.log_file = os.path.join(self.dir_log, 'fpdb-log.txt') self.log_file = os.path.join(self.dir_log, 'fpdb-log.txt')
@ -822,8 +824,12 @@ class Config:
try: imp['saveActions'] = self.imp.saveActions try: imp['saveActions'] = self.imp.saveActions
except: imp['saveActions'] = True except: imp['saveActions'] = True
try: imp['saveStarsHH'] = self.imp.saveStarsHH
except: imp['saveStarsHH'] = False
try: imp['fastStoreHudCache'] = self.imp.fastStoreHudCache try: imp['fastStoreHudCache'] = self.imp.fastStoreHudCache
except: imp['fastStoreHudCache'] = True except: imp['fastStoreHudCache'] = True
return imp return imp
def get_default_paths(self, site = None): def get_default_paths(self, site = None):

View File

@ -61,7 +61,7 @@ import Hud
# get config and set up logger # 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') 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: try:
if not options.errorsToConsole: if not options.errorsToConsole:
fileName = os.path.join(self.config.dir_log, 'HUD-errors.txt') fileName = os.path.join(self.config.dir_log, 'HUD-errors.txt')
print "Note: error output is being diverted to:\n"+fileName \ print "Note: error output is being diverted to:\n"+fileName \
+ "\nAny major error will be reported there _only_.\n" + "\nAny major error will be reported there _only_.\n"
log.info("Note: error output is being diverted to:"+fileName) log.info("Note: error output is being diverted to:"+fileName)
log.info("Any major error will be reported there _only_.") log.info("Any major error will be reported there _only_.")
errorFile = open(fileName, 'w', 0) errorFile = open(fileName, 'w', 0)
sys.stderr = errorFile sys.stderr = errorFile
sys.stderr.write("HUD_main: starting ...\n") sys.stderr.write("HUD_main: starting ...\n")
self.hud_dict = {} self.hud_dict = {}
self.hud_params = self.config.get_hud_ui_parameters() self.hud_params = self.config.get_hud_ui_parameters()
@ -237,7 +237,7 @@ class HUD_main(object):
try: try:
(table_name, max, poker_game, type, site_id, site_name, num_seats, tour_number, tab_number) = \ (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) self.db_connection.get_table_info(new_hand_id)
except Exception, err: except Exception:
log.error("db error: skipping %s" % new_hand_id) log.error("db error: skipping %s" % new_hand_id)
continue continue
t1 = time.time() t1 = time.time()

View File

@ -69,6 +69,7 @@ out_path (default '-' = sys.stdout)
follow : whether to tail -f the input""" follow : whether to tail -f the input"""
self.config = config 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 = 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) ) 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 == '-': if in_path == '-':
self.in_fh = sys.stdin 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.follow = follow
self.compiledPlayers = set() self.compiledPlayers = set()
self.maxseats = 10 self.maxseats = 10
@ -446,8 +443,8 @@ or None if we fail to get the info """
def guessMaxSeats(self, hand): def guessMaxSeats(self, hand):
"""Return a guess at maxseats when not specified in HH.""" """Return a guess at maxseats when not specified in HH."""
# if some other code prior to this has already set it, return it # if some other code prior to this has already set it, return it
if maxseats > 1 and maxseats < 11: if self.maxseats > 1 and self.maxseats < 11:
return maxseats return self.maxseats
mo = self.maxOccSeat(hand) mo = self.maxOccSeat(hand)
if mo == 10: return 10 #that was easy if mo == 10: return 10 #that was easy
@ -515,3 +512,23 @@ def getSiteHhc(config, sitename):
hhcName = config.supported_sites[sitename].converter hhcName = config.supported_sites[sitename].converter
hhcModule = __import__(hhcName) hhcModule = __import__(hhcName)
return getattr(hhcModule, hhcName[:-6]) 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)

View File

@ -89,7 +89,6 @@ class Table(Table_Window):
# break # break
if window_number is None: if window_number is None:
print "Window %s not found. Skipping." % search_string
return None return None
# my_geo = self.window.get_geometry() # my_geo = self.window.get_geometry()

View File

@ -1025,23 +1025,24 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
return response return response
def validate_config(self): def validate_config(self):
hhbase = self.config.get_import_parameters().get("hhArchiveBase") if self.config.get_import_parameters().get('saveStarsHH'):
hhbase = os.path.expanduser(hhbase) hhbase = self.config.get_import_parameters().get("hhArchiveBase")
#hhdir = os.path.join(hhbase,site) hhbase = os.path.expanduser(hhbase)
hhdir = hhbase #hhdir = os.path.join(hhbase,site)
if not os.path.isdir(hhdir): hhdir = hhbase
diapath = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=(gtk.BUTTONS_YES_NO), message_format="Setup hh dir") if not os.path.isdir(hhdir):
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 = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING, buttons=(gtk.BUTTONS_YES_NO), message_format="Setup hh dir")
diapath.format_secondary_text(diastring) 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
response = diapath.run() diapath.format_secondary_text(diastring)
diapath.destroy() response = diapath.run()
if response == gtk.RESPONSE_YES: diapath.destroy()
try: if response == gtk.RESPONSE_YES:
os.makedirs(hhdir) try:
except: os.makedirs(hhdir)
self.warning_box("WARNING: Unable to create hand output directory. Importing is not likely to work until this is fixed.") except:
elif response == gtk.RESPONSE_NO: self.warning_box("WARNING: Unable to create hand output directory. Importing is not likely to work until this is fixed.")
self.select_hhArchiveBase() elif response == gtk.RESPONSE_NO:
self.select_hhArchiveBase()
def select_hhArchiveBase(self, widget=None): 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) 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)