From aea7db22e367bee92eda58ebc72e2ef3808333d0 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Mon, 1 Feb 2010 18:37:36 -0500 Subject: [PATCH 1/8] Options for logging level and version. Not connected yet. --- pyfpdb/Options.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Options.py b/pyfpdb/Options.py index ab226124..6570dbe4 100644 --- a/pyfpdb/Options.py +++ b/pyfpdb/Options.py @@ -15,9 +15,9 @@ #In the "official" distribution you can find the license in #agpl-3.0.txt in the docs folder of the package. -import os import sys from optparse import OptionParser +# http://docs.python.org/library/optparse.html def fpdb_options(): @@ -41,6 +41,14 @@ def fpdb_options(): parser.add_option("-k", "--konverter", dest="hhc", default="PokerStarsToFpdb", help="Module name for Hand History Converter") + parser.add_option("-l", "--logging", + dest = "log_level", + choices = ('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL', 'EMPTY'), + help = "Error logging level. (DEBUG, INFO, WARNING, ERROR, CRITICAL, EMPTY)", + default = 'EMPTY') + parser.add_option("-v", "--version", action = "store_true", + help = "Print version information and exit.") + (options, argv) = parser.parse_args() return (options, argv) From 9dfa0967b8fc571650ab2241a496720f281085fe Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Thu, 4 Feb 2010 13:08:26 -0500 Subject: [PATCH 2/8] Correct data files. --- pyfpdb/py2exe_setup.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyfpdb/py2exe_setup.py b/pyfpdb/py2exe_setup.py index 9565ac0b..1e1ddc6b 100644 --- a/pyfpdb/py2exe_setup.py +++ b/pyfpdb/py2exe_setup.py @@ -58,8 +58,8 @@ setup( options = {'py2exe': { 'packages' :'encodings', - 'includes' : 'cairo, pango, pangocairo, atk, gobject, PokerStarsToFpdb', - 'excludes' : '_tkagg, _agg2, cocoaagg, fltkagg', + 'includes' : 'cairo, pango, pangocairo, atk, gobject, PokerStarsToFpdb, FulltiltToFpdb', + 'excludes' : '_tkagg, _agg2, cocoaagg, fltkagg', 'dll_excludes': 'libglade-2.0-0.dll', } }, @@ -67,7 +67,9 @@ setup( data_files = ['HUD_config.xml.example', 'Cards01.png', 'logging.conf', - (r'matplotlibdata', glob.glob(r'c:\python26\Lib\site-packages\matplotlib\mpl-data\*')) + (r'mpl-data', [r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\matplotlibrc']), + (r'mpl-data\images', glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\images\*.*')), + (r'mpl-data\fonts', glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\fonts\*.*')),) ] ) From 08078cfee4dd50e84a92e71b0d92725695e18eb0 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Fri, 5 Feb 2010 23:03:55 -0500 Subject: [PATCH 3/8] Configure for python 2.5. Add icon for fpdb.exe. --- pyfpdb/py2exe_setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyfpdb/py2exe_setup.py b/pyfpdb/py2exe_setup.py index 1e1ddc6b..6391194f 100644 --- a/pyfpdb/py2exe_setup.py +++ b/pyfpdb/py2exe_setup.py @@ -45,13 +45,14 @@ Py2exe script for fpdb. from distutils.core import setup import py2exe +import glob setup( name = 'fpdb', description = 'Free Poker DataBase', version = '0.12', - console = [ {'script': 'fpdb.py', }, + console = [ {'script': 'fpdb.py', "icon_resources": [(1, "../gfx/fpdb_large_icon.ico")]}, {'script': 'HUD_main.py', }, {'script': 'Configuration.py', } ], @@ -69,7 +70,7 @@ setup( 'logging.conf', (r'mpl-data', [r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\matplotlibrc']), (r'mpl-data\images', glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\images\*.*')), - (r'mpl-data\fonts', glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\fonts\*.*')),) + (r'mpl-data\fonts', glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\fonts\*.*')), ] ) From 4df991517e0fdd22e1013438ece31f7dc4624294 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Fri, 5 Feb 2010 23:13:53 -0500 Subject: [PATCH 4/8] Changes to make the py2exe exe happy. --- pyfpdb/Configuration.py | 13 ++++++++++++- pyfpdb/GuiAutoImport.py | 7 ++++++- 2 files changed, 18 insertions(+), 2 deletions(-) mode change 100755 => 100644 pyfpdb/Configuration.py mode change 100755 => 100644 pyfpdb/GuiAutoImport.py diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py old mode 100755 new mode 100644 index ec4c621e..f87cd049 --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -166,6 +166,10 @@ if LOCALE_ENCODING == "US-ASCII": # needs LOCALE_ENCODING (above), imported for sqlite setup in Config class below + +FROZEN = hasattr(sys, "frozen") +EXEC_PATH = get_exec_path() + import Charset @@ -613,7 +617,8 @@ class Config: def save(self, file = None): if file is None: file = self.file - shutil.move(file, file+".backup") + shutil.move(file, file+".backup", ignore_errors = True) + with open(file, 'w') as f: self.doc.writexml(f) @@ -1030,3 +1035,9 @@ if __name__== "__main__": PrettyPrint(site_node, stream=sys.stdout, encoding="utf-8") except: print "xml.dom.ext needs PyXML to be installed!" + + print "FROZEN =", FROZEN + print "EXEC_PATH =", EXEC_PATH + + print "press enter to end" + sys.stdin.readline() diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py old mode 100755 new mode 100644 index 339ce968..f8150500 --- a/pyfpdb/GuiAutoImport.py +++ b/pyfpdb/GuiAutoImport.py @@ -193,7 +193,11 @@ class GuiAutoImport (threading.Thread): self.doAutoImportBool = True widget.set_label(u' _Stop Autoimport ') if self.pipe_to_hud is None: - if os.name == 'nt': + if Configuration.FROZEN: + path = Configuration.EXEC_PATH + command = "HUD_main.exe" + bs = 0 + elif os.name == 'nt': path = sys.path[0].replace('\\','\\\\') command = 'python "'+path+'\\HUD_main.py" ' + self.settings['cl_options'] bs = 0 @@ -203,6 +207,7 @@ class GuiAutoImport (threading.Thread): bs = 1 try: + print "opening pipe to HUD" self.pipe_to_hud = subprocess.Popen(command, bufsize=bs, stdin=subprocess.PIPE, universal_newlines=True) From 8aa18b95d829781091eb585a27afd8291238a9cd Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Fri, 5 Feb 2010 23:19:58 -0500 Subject: [PATCH 5/8] Changes to make running py2exe exe happy. --- pyfpdb/Configuration.py | 13 +------------ pyfpdb/GuiAutoImport.py | 7 +------ 2 files changed, 2 insertions(+), 18 deletions(-) mode change 100644 => 100755 pyfpdb/Configuration.py mode change 100644 => 100755 pyfpdb/GuiAutoImport.py diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py old mode 100644 new mode 100755 index f87cd049..ec4c621e --- a/pyfpdb/Configuration.py +++ b/pyfpdb/Configuration.py @@ -166,10 +166,6 @@ if LOCALE_ENCODING == "US-ASCII": # needs LOCALE_ENCODING (above), imported for sqlite setup in Config class below - -FROZEN = hasattr(sys, "frozen") -EXEC_PATH = get_exec_path() - import Charset @@ -617,8 +613,7 @@ class Config: def save(self, file = None): if file is None: file = self.file - shutil.move(file, file+".backup", ignore_errors = True) - + shutil.move(file, file+".backup") with open(file, 'w') as f: self.doc.writexml(f) @@ -1035,9 +1030,3 @@ if __name__== "__main__": PrettyPrint(site_node, stream=sys.stdout, encoding="utf-8") except: print "xml.dom.ext needs PyXML to be installed!" - - print "FROZEN =", FROZEN - print "EXEC_PATH =", EXEC_PATH - - print "press enter to end" - sys.stdin.readline() diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py old mode 100644 new mode 100755 index f8150500..339ce968 --- a/pyfpdb/GuiAutoImport.py +++ b/pyfpdb/GuiAutoImport.py @@ -193,11 +193,7 @@ class GuiAutoImport (threading.Thread): self.doAutoImportBool = True widget.set_label(u' _Stop Autoimport ') if self.pipe_to_hud is None: - if Configuration.FROZEN: - path = Configuration.EXEC_PATH - command = "HUD_main.exe" - bs = 0 - elif os.name == 'nt': + if os.name == 'nt': path = sys.path[0].replace('\\','\\\\') command = 'python "'+path+'\\HUD_main.py" ' + self.settings['cl_options'] bs = 0 @@ -207,7 +203,6 @@ class GuiAutoImport (threading.Thread): bs = 1 try: - print "opening pipe to HUD" self.pipe_to_hud = subprocess.Popen(command, bufsize=bs, stdin=subprocess.PIPE, universal_newlines=True) From 120d05f9cde9f0159b89f84807af36c4f91f6184 Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Sat, 6 Feb 2010 14:55:48 -0500 Subject: [PATCH 6/8] Changes for py2exe exe. --- pyfpdb/GuiAutoImport.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py index 339ce968..f8150500 100755 --- a/pyfpdb/GuiAutoImport.py +++ b/pyfpdb/GuiAutoImport.py @@ -193,7 +193,11 @@ class GuiAutoImport (threading.Thread): self.doAutoImportBool = True widget.set_label(u' _Stop Autoimport ') if self.pipe_to_hud is None: - if os.name == 'nt': + if Configuration.FROZEN: + path = Configuration.EXEC_PATH + command = "HUD_main.exe" + bs = 0 + elif os.name == 'nt': path = sys.path[0].replace('\\','\\\\') command = 'python "'+path+'\\HUD_main.py" ' + self.settings['cl_options'] bs = 0 @@ -203,6 +207,7 @@ class GuiAutoImport (threading.Thread): bs = 1 try: + print "opening pipe to HUD" self.pipe_to_hud = subprocess.Popen(command, bufsize=bs, stdin=subprocess.PIPE, universal_newlines=True) From e0777d6f0d110aabf4e3b34ee38f1ffe121dfaad Mon Sep 17 00:00:00 2001 From: Eratosthenes Date: Sun, 7 Feb 2010 12:36:41 -0500 Subject: [PATCH 7/8] Add windows icon file. --- gfx/fpdb_large_icon.ico | Bin 0 -> 4286 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 gfx/fpdb_large_icon.ico diff --git a/gfx/fpdb_large_icon.ico b/gfx/fpdb_large_icon.ico new file mode 100644 index 0000000000000000000000000000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+0200 Subject: [PATCH 8/8] Modify display of 'n' in HUD for large numbers When sample size grows to larger than 1000, use "X.Yk" notation to show the approximate value. --- pyfpdb/Stats.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Stats.py b/pyfpdb/Stats.py index 18913eed..ab92c99f 100755 --- a/pyfpdb/Stats.py +++ b/pyfpdb/Stats.py @@ -245,8 +245,20 @@ def saw_f(stat_dict, player): def n(stat_dict, player): """ Number of hands played.""" try: + # If sample is large enough, use X.Yk notation instead + _n = stat_dict[player]['n'] + fmt = '%d' % _n + if _n >= 1000: + k = _n / 1000 + c = _n % 1000 + _c = float(c) / 100.0 + d = int(round(_c)) + if d == 10: + k += 1 + d = 0 + fmt = '%d.%dk' % (k, d) return (stat_dict[player]['n'], - '%d' % (stat_dict[player]['n']), + '%s' % fmt, 'n=%d' % (stat_dict[player]['n']), 'n=%d' % (stat_dict[player]['n']), '(%d)' % (stat_dict[player]['n']),