Merge branch 'master' of git://git.assembla.com/fpdb-sql

This commit is contained in:
Worros 2010-06-13 13:33:02 +08:00
commit 498eb486b5
8 changed files with 98 additions and 25 deletions

View File

@ -32,6 +32,7 @@ import string
import traceback import traceback
import shutil import shutil
import locale import locale
import re
import xml.dom.minidom import xml.dom.minidom
from xml.dom.minidom import Node from xml.dom.minidom import Node
@ -248,6 +249,8 @@ class Site:
self.enabled = string_to_bool(node.getAttribute("enabled"), default=True) self.enabled = string_to_bool(node.getAttribute("enabled"), default=True)
self.xpad = node.getAttribute("xpad") self.xpad = node.getAttribute("xpad")
self.ypad = node.getAttribute("ypad") self.ypad = node.getAttribute("ypad")
self.xshift = node.getAttribute("xshift")
self.yshift = node.getAttribute("yshift")
self.layout = {} self.layout = {}
print "Loading site", self.site_name print "Loading site", self.site_name
@ -259,6 +262,8 @@ class Site:
# Site defaults # Site defaults
self.xpad = 1 if self.xpad == "" else int(self.xpad) self.xpad = 1 if self.xpad == "" else int(self.xpad)
self.ypad = 0 if self.ypad == "" else int(self.ypad) self.ypad = 0 if self.ypad == "" else int(self.ypad)
self.xshift = 1 if self.xshift == "" else int(self.xshift)
self.yshift = 0 if self.yshift == "" else int(self.yshift)
self.font_size = 7 if self.font_size == "" else int(self.font_size) self.font_size = 7 if self.font_size == "" else int(self.font_size)
self.hudopacity = 1.0 if self.hudopacity == "" else float(self.hudopacity) self.hudopacity = 1.0 if self.hudopacity == "" else float(self.hudopacity)
@ -296,12 +301,18 @@ class Game:
self.cols = int( node.getAttribute("cols") ) self.cols = int( node.getAttribute("cols") )
self.xpad = node.getAttribute("xpad") self.xpad = node.getAttribute("xpad")
self.ypad = node.getAttribute("ypad") self.ypad = node.getAttribute("ypad")
self.xshift = node.getAttribute("xshift")
self.yshift = node.getAttribute("yshift")
# Defaults # Defaults
if self.xpad == "": self.xpad = 1 if self.xpad == "": self.xpad = 1
else: self.xpad = int(self.xpad) else: self.xpad = int(self.xpad)
if self.ypad == "": self.ypad = 0 if self.ypad == "": self.ypad = 0
else: self.ypad = int(self.ypad) else: self.ypad = int(self.ypad)
if self.xshift == "": self.xshift = 1
else: self.xshift = int(self.xshift)
if self.yshift == "": self.yshift = 0
else: self.yshift = int(self.yshift)
aux_text = node.getAttribute("aux") aux_text = node.getAttribute("aux")
aux_list = aux_text.split(',') aux_list = aux_text.split(',')
@ -334,6 +345,8 @@ class Game:
temp = temp + " cols = %d\n" % self.cols temp = temp + " cols = %d\n" % self.cols
temp = temp + " xpad = %d\n" % self.xpad temp = temp + " xpad = %d\n" % self.xpad
temp = temp + " ypad = %d\n" % self.ypad temp = temp + " ypad = %d\n" % self.ypad
temp = temp + " xshift = %d\n" % self.xshift
temp = temp + " yshift = %d\n" % self.yshift
temp = temp + " aux = %s\n" % self.aux temp = temp + " aux = %s\n" % self.aux
for stat in self.stats.keys(): for stat in self.stats.keys():
@ -662,7 +675,34 @@ class Config:
pass pass
with open(file, 'w') as f: with open(file, 'w') as f:
self.doc.writexml(f) #self.doc.writexml(f)
f.write( self.wrap_long_lines( self.doc.toxml() ) )
def wrap_long_lines(self, s):
lines = [ self.wrap_long_line(l) for l in s.splitlines() ]
return('\n'.join(lines) + '\n')
def wrap_long_line(self, l):
if 'config_wrap_len' in self.general:
wrap_len = int(self.general['config_wrap_len'])
else:
wrap_len = -1 # < 0 means no wrap
if wrap_len >= 0 and len(l) > wrap_len:
m = re.compile('\s+\S+\s+')
mo = m.match(l)
if mo:
indent_len = mo.end()
#print "indent = %s (%s)" % (indent_len, l[0:indent_len])
indent = '\n' + ' ' * indent_len
m = re.compile('(\S+="[^"]+"\s+)')
parts = [x for x in m.split(l[indent_len:]) if x]
if len(parts) > 1:
#print "parts =", parts
l = l[0:indent_len] + indent.join(parts)
return(l)
else:
return(l)
def edit_layout(self, site_name, max, width = None, height = None, def edit_layout(self, site_name, max, width = None, height = None,
fav_seat = None, locations = None): fav_seat = None, locations = None):
@ -951,6 +991,8 @@ class Config:
parms["enabled"] = self.supported_sites[site].enabled parms["enabled"] = self.supported_sites[site].enabled
parms["xpad"] = self.supported_sites[site].xpad parms["xpad"] = self.supported_sites[site].xpad
parms["ypad"] = self.supported_sites[site].ypad parms["ypad"] = self.supported_sites[site].ypad
parms["xshift"] = self.supported_sites[site].xshift
parms["yshift"] = self.supported_sites[site].yshift
return parms return parms
def set_site_parameters(self, site_name, converter = None, decoder = None, def set_site_parameters(self, site_name, converter = None, decoder = None,
@ -1002,6 +1044,8 @@ class Config:
param['cols'] = self.supported_games[name].cols param['cols'] = self.supported_games[name].cols
param['xpad'] = self.supported_games[name].xpad param['xpad'] = self.supported_games[name].xpad
param['ypad'] = self.supported_games[name].ypad param['ypad'] = self.supported_games[name].ypad
param['xshift'] = self.supported_games[name].xshift
param['yshift'] = self.supported_games[name].yshift
param['aux'] = self.supported_games[name].aux param['aux'] = self.supported_games[name].aux
return param return param

View File

@ -214,8 +214,8 @@ class GuiAutoImport (threading.Thread):
stderr=subprocess.PIPE, # only needed for py2exe stderr=subprocess.PIPE, # only needed for py2exe
universal_newlines=True universal_newlines=True
) )
self.pipe_to_hud.stdout.close() #self.pipe_to_hud.stdout.close()
self.pipe_to_hud.stderr.close() #self.pipe_to_hud.stderr.close()
except: except:
err = traceback.extract_tb(sys.exc_info()[2])[-1] err = traceback.extract_tb(sys.exc_info()[2])[-1]
#self.addText( "\n*** GuiAutoImport Error opening pipe: " + err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1])) #self.addText( "\n*** GuiAutoImport Error opening pipe: " + err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1]))

View File

@ -228,9 +228,9 @@ class GuiGraphViewer (threading.Thread):
self.ax.plot(blue, color='blue', label='Showdown: $%.2f' %(blue[-1])) self.ax.plot(blue, color='blue', label='Showdown: $%.2f' %(blue[-1]))
self.ax.plot(red, color='red', label='Non-showdown: $%.2f' %(red[-1])) self.ax.plot(red, color='red', label='Non-showdown: $%.2f' %(red[-1]))
if sys.version[0:3] == '2.5': if sys.version[0:3] == '2.5':
self.ax.legend(loc='best', shadow=True, prop=FontProperties(size='smaller')) self.ax.legend(loc='upper left', shadow=True, prop=FontProperties(size='smaller'))
else: else:
self.ax.legend(loc='best', fancybox=True, shadow=True, prop=FontProperties(size='smaller')) self.ax.legend(loc='upper left', fancybox=True, shadow=True, prop=FontProperties(size='smaller'))
self.graphBox.add(self.canvas) self.graphBox.add(self.canvas)
self.canvas.show() self.canvas.show()

View File

@ -60,7 +60,7 @@ class GuiPrefs:
configColumn.pack_start(cRender, True) configColumn.pack_start(cRender, True)
configColumn.add_attribute(cRender, 'text', 1) configColumn.add_attribute(cRender, 'text', 1)
configColumn = gtk.TreeViewColumn("Value") configColumn = gtk.TreeViewColumn("Value (double-click to change)")
self.configView.append_column(configColumn) self.configView.append_column(configColumn)
cRender = gtk.CellRendererText() cRender = gtk.CellRendererText()
configColumn.pack_start(cRender, True) configColumn.pack_start(cRender, True)

View File

@ -2,6 +2,11 @@
<FreePokerToolsConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FreePokerToolsConfig.xsd"> <FreePokerToolsConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FreePokerToolsConfig.xsd">
<general config_wrap_len="-1" <!-- preferred max line length in this file, -1 means no max -->
day_start="5" <!-- time that logical day starts, e.g. 5 means that any play
between 00:00 and 04:59:59 counts as being on the previous day -->
/>
<import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True"></import> <import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True"></import>
<!-- These values determine what stats are displayed in the HUD <!-- These values determine what stats are displayed in the HUD
@ -114,6 +119,10 @@ Left-Drag to Move"
hudopacity="1.0" hudopacity="1.0"
font="Sans" font="Sans"
font_size="8" font_size="8"
xpad="1"
ypad="0"
xshift="0"
yshift="0"
supported_games="holdem,razz,omahahi,omahahilo,studhi,studhilo"> supported_games="holdem,razz,omahahi,omahahilo,studhi,studhilo">
<layout max="8" width="792" height="546" fav_seat="0"> <layout max="8" width="792" height="546" fav_seat="0">
<location seat="1" x="684" y="61"> </location> <location seat="1" x="684" y="61"> </location>

View File

@ -87,6 +87,7 @@ class Hud:
(font, font_size) = config.get_default_font(self.table.site) (font, font_size) = config.get_default_font(self.table.site)
self.colors = config.get_default_colors(self.table.site) self.colors = config.get_default_colors(self.table.site)
self.hud_ui = config.get_hud_ui_parameters() self.hud_ui = config.get_hud_ui_parameters()
self.site_params = config.get_site_parameters(self.table.site)
self.backgroundcolor = gtk.gdk.color_parse(self.colors['hudbgcolor']) self.backgroundcolor = gtk.gdk.color_parse(self.colors['hudbgcolor'])
self.foregroundcolor = gtk.gdk.color_parse(self.colors['hudfgcolor']) self.foregroundcolor = gtk.gdk.color_parse(self.colors['hudfgcolor'])
@ -457,7 +458,7 @@ class Hud:
if self.table.x != x or self.table.y != y: if self.table.x != x or self.table.y != y:
self.table.x = x self.table.x = x
self.table.y = y self.table.y = y
self.main_window.move(x, y) self.main_window.move(x + self.site_params['xshift'], y + self.site_params['yshift'])
adj = self.adj_seats(self.hand, self.config) adj = self.adj_seats(self.hand, self.config)
loc = self.config.get_locations(self.table.site, self.max) loc = self.config.get_locations(self.table.site, self.max)
# TODO: is stat_windows getting converted somewhere from a list to a dict, for no good reason? # TODO: is stat_windows getting converted somewhere from a list to a dict, for no good reason?

View File

@ -35,7 +35,7 @@ if os.name == 'nt' and sys.version[0:3] not in ('2.5', '2.6') and '-r' not in sy
os.environ['PATH'] = tmppath os.environ['PATH'] = tmppath
print "Python " + sys.version[0:3] + ' - press return to continue\n' print "Python " + sys.version[0:3] + ' - press return to continue\n'
sys.stdin.readline() sys.stdin.readline()
os.execvpe('python.exe', ('python.exe', 'fpdb.py', '-r'), os.environ) # first arg is ignored (name of program being run) os.execvpe('pythonw.exe', ('pythonw.exe', 'fpdb.pyw', '-r'), os.environ) # first arg is ignored (name of program being run)
else: else:
print "\npython 2.5 not found, please install python 2.5 or 2.6 for fpdb\n" print "\npython 2.5 not found, please install python 2.5 or 2.6 for fpdb\n"
raw_input("Press ENTER to continue.") raw_input("Press ENTER to continue.")

View File

@ -39,16 +39,14 @@ Py2exe script for fpdb.
# MSVCP90.dll. These are somewhere in your windows install, so you # MSVCP90.dll. These are somewhere in your windows install, so you
# can just copy them to your working folder. (or just assume other # can just copy them to your working folder. (or just assume other
# person will have them? any copyright issues with including them?) # person will have them? any copyright issues with including them?)
#- [ If it works, you'll have 3 new folders, build and dist and gfx. Build is #- If it works, you'll have a new dir fpdb-YYYYMMDD-exe which should
# working space and should be deleted. Dist and gfx contain the files to be
# distributed. ]
# If it works, you'll have a new dir fpdb-XXX-YYYYMMDD-exe which should
# contain 2 dirs; gfx and pyfpdb and run_fpdb.bat # contain 2 dirs; gfx and pyfpdb and run_fpdb.bat
#- Last, you must copy the etc/, lib/ and share/ folders from your #- [ This bit is now automated:
# gtk/bin/ (just /gtk/?) folder to the pyfpdb folder. (the whole folders, # Last, you must copy the etc/, lib/ and share/ folders from your
# not just the contents) # gtk/bin/ (just /gtk/?) folder to the pyfpdb folder. (the whole folders,
# not just the contents) ]
#- You can (should) then prune the etc/, lib/ and share/ folders to #- You can (should) then prune the etc/, lib/ and share/ folders to
# remove components we don't need. # remove components we don't need. (see output at end of program run)
# sqlcoder notes: this worked for me with the following notes: # sqlcoder notes: this worked for me with the following notes:
#- I used the following versions: #- I used the following versions:
@ -116,11 +114,11 @@ test_and_remove('build')
today = date.today().strftime('%Y%m%d') today = date.today().strftime('%Y%m%d')
print "\n" + r"Output will be created in \pyfpdb\ and \fpdb_XXX_"+today+'\\' print "\n" + r"Output will be created in \pyfpdb\ and \fpdb_"+today+'\\'
print "Enter value for XXX (any length): ", # the comma means no newline #print "Enter value for XXX (any length): ", # the comma means no newline
xxx = sys.stdin.readline().rstrip() #xxx = sys.stdin.readline().rstrip()
dist_dirname = r'fpdb-' + xxx + '-' + today + '-exe' dist_dirname = r'fpdb-' + today + '-exe'
dist_dir = r'..\fpdb-' + xxx + '-' + today + '-exe' dist_dir = r'..\fpdb-' + today + '-exe'
print print
test_and_remove(dist_dir) test_and_remove(dist_dir)
@ -163,10 +161,11 @@ setup(
os.rename('dist', 'pyfpdb') os.rename('dist', 'pyfpdb')
print '\n' + 'If py2exe was successful add the \\etc \\lib and \\share dirs ' # these instructions no longer needed:
print 'from your gtk dir to \\%s\\pyfpdb\\\n' % dist_dirname #print '\n' + 'If py2exe was successful add the \\etc \\lib and \\share dirs '
print 'Also copy libgobject-2.0-0.dll and libgdk-win32-2.0-0.dll from <gtk_dir>\\bin' #print 'from your gtk dir to \\%s\\pyfpdb\\\n' % dist_dirname
print 'into there' #print 'Also copy libgobject-2.0-0.dll and libgdk-win32-2.0-0.dll from <gtk_dir>\\bin'
#print 'into there'
dest = os.path.join(dist_dirname, 'pyfpdb') dest = os.path.join(dist_dirname, 'pyfpdb')
#print "try renaming pyfpdb to", dest #print "try renaming pyfpdb to", dest
@ -207,4 +206,24 @@ dest_dir = os.path.join(dest, 'share')
dest_dir = dest_dir.replace('\\', '\\\\') dest_dir = dest_dir.replace('\\', '\\\\')
shutil.copytree( src_dir, dest_dir ) shutil.copytree( src_dir, dest_dir )
print "\nIf py2exe was successful you should now have a new dir"
print dist_dirname+" in your pyfpdb dir"
print """
The following dirs can probably removed to make the final package smaller:
pyfpdb/lib/glib-2.0
pyfpdb/lib/gtk-2.0/include
pyfpdb/lib/pkgconfig
pyfpdb/share/aclocal
pyfpdb/share/doc
pyfpdb/share/glib-2.0
pyfpdb/share/gtk-2.0
pyfpdb/share/gtk-doc
pyfpdb/share/locale
pyfpdb/share/man
pyfpdb/share/themes/Default
Use 7-zip to zip up the distribution and create a self extracting archive and that's it!
"""