From dd74c29551d865b501e00d7704cd2ae4c520dba1 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Thu, 6 Nov 2008 23:58:41 +0000 Subject: [PATCH 1/8] p139 - fixed TV and removed old config --- docs/default.conf | 11 --------- pyfpdb/GuiTableViewer.py | 49 +++++++++++----------------------------- 2 files changed, 13 insertions(+), 47 deletions(-) delete mode 100644 docs/default.conf diff --git a/docs/default.conf b/docs/default.conf deleted file mode 100644 index 031b8fb7..00000000 --- a/docs/default.conf +++ /dev/null @@ -1,11 +0,0 @@ -db-backend=2 -db-host=localhost -db-databaseName=fpdb -db-user=fpdb -db-password=enterYourPwHere -imp-callFpdbHud=True -tv-combinedStealFold=True -tv-combined2B3B=True -tv-combinedPostflop=True -bulkImport-defaultPath=default -hud-defaultPath=default diff --git a/pyfpdb/GuiTableViewer.py b/pyfpdb/GuiTableViewer.py index 1082bff1..f024a193 100644 --- a/pyfpdb/GuiTableViewer.py +++ b/pyfpdb/GuiTableViewer.py @@ -78,22 +78,13 @@ class GuiTableViewer (threading.Thread): if (self.category=="holdem" or self.category=="omahahi" or self.category=="omahahilo"): tmp=("Name", "HDs", "VPIP", "PFR", "PF3B4B", "ST") - if self.settings['tv-combinedStealFold']: - tmp+=("FSB", ) - else: - tmp+=("FS", "FB") + tmp+=("FS", "FB") tmp+=("CB", ) - if self.settings['tv-combined2B3B']: - tmp+=("23B", ) - else: - tmp+=("2B", "3B") + tmp+=("2B", "3B") - if self.settings['tv-combinedPostflop']: - tmp+=("Postf A", "Postf F") - else: - tmp+=("AF", "FF", "AT", "FT", "AR", "FR") + tmp+=("AF", "FF", "AT", "FT", "AR", "FR") tmp+=("WtSD", "W$wsF", "W$SD") else: @@ -144,34 +135,20 @@ class GuiTableViewer (threading.Thread): tmp.append(self.hudDivide(row[31],row[30])+" ("+str(row[30])+")") #ST - if self.settings['tv-combinedStealFold']: - tmp.append(self.hudDivide(row[35]+row[33],row[34]+row[32])+" ("+str(row[34]+row[32])+")") #FSB - else: - tmp.append(self.hudDivide(row[35],row[34])+" ("+str(row[34])+")") #FS - tmp.append(self.hudDivide(row[33],row[32])+" ("+str(row[32])+")") #FB + tmp.append(self.hudDivide(row[35],row[34])+" ("+str(row[34])+")") #FS + tmp.append(self.hudDivide(row[33],row[32])+" ("+str(row[32])+")") #FB tmp.append(self.hudDivide(row[37],row[36])+" ("+str(row[36])+")") #CB - if self.settings['tv-combined2B3B']: - tmp.append(self.hudDivide(row[39]+row[41],row[38]+row[40])+" ("+str(row[38]+row[40])+")") #23B - else: - tmp.append(self.hudDivide(row[39],row[38])+" ("+str(row[38])+")") #2B - tmp.append(self.hudDivide(row[41],row[40])+" ("+str(row[40])+")") #3B + tmp.append(self.hudDivide(row[39],row[38])+" ("+str(row[38])+")") #2B + tmp.append(self.hudDivide(row[41],row[40])+" ("+str(row[40])+")") #3B - if self.settings['tv-combinedPostflop']: - aggCount=row[16]+row[17]+row[18] - handCount=row[11]+row[12]+row[13] - foldCount=row[24]+row[25]+row[26] - otherRaiseCount=row[20]+row[21]+row[22] - tmp.append(self.hudDivide(aggCount,handCount)+" ("+str(handCount)+")") #Agg - tmp.append(self.hudDivide(foldCount,otherRaiseCount)+" ("+str(otherRaiseCount)+")") #FF - else: - tmp.append(self.hudDivide(row[16],row[11])+" ("+str(row[11])+")") #AF - tmp.append(self.hudDivide(row[24],row[20])+" ("+str(row[20])+")") #FF - tmp.append(self.hudDivide(row[17],row[12])+" ("+str(row[12])+")") #AT - tmp.append(self.hudDivide(row[25],row[21])+" ("+str(row[21])+")") #FT - tmp.append(self.hudDivide(row[18],row[13])+" ("+str(row[13])+")") #AR - tmp.append(self.hudDivide(row[26],row[22])+" ("+str(row[22])+")") #FR + tmp.append(self.hudDivide(row[16],row[11])+" ("+str(row[11])+")") #AF + tmp.append(self.hudDivide(row[24],row[20])+" ("+str(row[20])+")") #FF + tmp.append(self.hudDivide(row[17],row[12])+" ("+str(row[12])+")") #AT + tmp.append(self.hudDivide(row[25],row[21])+" ("+str(row[21])+")") #FT + tmp.append(self.hudDivide(row[18],row[13])+" ("+str(row[13])+")") #AR + tmp.append(self.hudDivide(row[26],row[22])+" ("+str(row[22])+")") #FR tmp.append(self.hudDivide(row[15],row[11])) #WtSD tmp.append(self.hudDivide(row[28],row[11])) #W$wSF From c7393951893011df98986bd89b82af4df08d33cc Mon Sep 17 00:00:00 2001 From: steffen123 Date: Fri, 7 Nov 2008 00:14:25 +0000 Subject: [PATCH 2/8] p140 - added CLI option to fpdb.py to control redirection of stderr --- pyfpdb/fpdb.py | 14 +++++++++++--- pyfpdb/fpdb_import.py | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 134e6ea1..ad4d3f3d 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -17,10 +17,18 @@ import os import sys +from optparse import OptionParser -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 + +parser = OptionParser() +parser.add_option("-x", "--errorsToConsole", action="store_true", + help="If passed error output will go to the console rather than .") +(options, sys.argv) = parser.parse_args() + +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 pygtk pygtk.require('2.0') diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index ffa06cff..5398c83b 100755 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -292,4 +292,4 @@ class Importer: if __name__ == "__main__": - print "CLI for fpdb_import is currently on vacation please check in later" + print "CLI for fpdb_import is now available as CliFpdb.py" From 98d0305aa8102250d666fc52f6116400fd4b7ced Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 7 Nov 2008 11:07:42 -0500 Subject: [PATCH 3/8] fixed psycopg2 connection parameters --- pyfpdb/fpdb_import.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index ffa06cff..b43b5740 100755 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -72,8 +72,11 @@ class Importer: elif self.settings['db-backend'] == 3: if not pgsqlLibFound: raise fpdb_simple.FpdbError("interface library psycopg2 not found but PostgreSQL selected as backend - please install the library or change the config file") - self.db = psycopg2.connect(self.settings['db-host'], self.settings['db-user'], - self.settings['db-password'], self.settings['db-databaseName']) + print self.settings + self.db = psycopg2.connect(host = self.settings['db-host'], + user = self.settings['db-user'], + password = self.settings['db-password'], + database = self.settings['db-databaseName']) elif self.settings['db-backend'] == 4: pass else: From e26fdd79a4d484c44e8bcdd14d4e07a3f6ba8362 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 7 Nov 2008 12:22:37 -0500 Subject: [PATCH 4/8] possible fix to wrong window positioning seen by Elaetic --- pyfpdb/HUD_main.py | 39 +++++++++++++++++++++++++++++++-------- pyfpdb/Hud.py | 9 ++++++++- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index b1955a6b..f54fa9af 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -37,6 +37,7 @@ import os import thread import time import string +import re errorfile = open('HUD-error.txt', 'w', 0) sys.stderr = errorfile @@ -70,9 +71,10 @@ def create_HUD(new_hand_id, table, db_name, table_name, max, poker_game, db_conn hud_dict[table_name] = Hud.Hud(table, max, poker_game, config, db_name) hud_dict[table_name].create(new_hand_id, config) hud_dict[table_name].update(new_hand_id, config, stat_dict) + hud_dict[table_name].reposition_windows() return False finally: - gtk.gdk.threads_leave + gtk.gdk.threads_leave() gobject.idle_add(idle_func) def update_HUD(new_hand_id, table_name, config, stat_dict): @@ -83,13 +85,15 @@ def update_HUD(new_hand_id, table_name, config, stat_dict): hud_dict[table_name].update(new_hand_id, config, stat_dict) return False finally: - gtk.gdk.threads_leave + gtk.gdk.threads_leave() gobject.idle_add(idle_func) def read_stdin(): # This is the thread function global hud_dict db_connection = Database.Database(config, db_name, 'temp') +# tourny_finder = re.compile('(\d+) (\d+)') + while True: # wait for a new hand number on stdin new_hand_id = sys.stdin.readline() new_hand_id = string.rstrip(new_hand_id) @@ -101,20 +105,39 @@ def read_stdin(): # This is the thread function if hud_dict[h].deleted: del(hud_dict[h]) -# connect to the db and get basic info about the new hand +# get basic info about the new hand from the db (table_name, max, poker_game) = db_connection.get_table_name(new_hand_id) + +# find out if this hand is from a tournament + is_tournament = False +# (t_number, s_number) = (0, 0) +# mat_obj = tourny_finder(table_name) +# if len(mat_obj.groups) == 2: +# is_tournament = True +# (t_number, s_number) = mat_obj.group(1, 2) + stat_dict = db_connection.get_stats_from_hand(new_hand_id) -# if a hud for this table exists, just update it +# if a hud for this CASH table exists, just update it if hud_dict.has_key(table_name): update_HUD(new_hand_id, table_name, config, stat_dict) +# if a hud for this TOURNAMENT table exists, just update it +# elif hud_dict.has_key(t_number): +# update_HUD(new_hand_id, t_number, config, stat_dict) # otherwise create a new hud else: - tablewindow = Tables.discover_table_by_name(config, table_name) - if tablewindow == None: - sys.stderr.write("table name "+table_name+" not found\n") + if is_tournament: + tablewindow = Tables.discover_tournament_table(config, t_number, s_number) + if tablewindow == None: + sys.stderr.write("table name "+table_name+" not found\n") + else: + create_HUD(new_hand_id, tablewindow, db_name, t_number, max, poker_game, db_connection, config, stat_dict) else: - create_HUD(new_hand_id, tablewindow, db_name, table_name, max, poker_game, db_connection, config, stat_dict) + tablewindow = Tables.discover_table_by_name(config, table_name) + if tablewindow == None: + sys.stderr.write("table name "+table_name+" not found\n") + else: + create_HUD(new_hand_id, tablewindow, db_name, table_name, max, poker_game, db_connection, config, stat_dict) if __name__== "__main__": sys.stderr.write("HUD_main starting\n") diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 2712c55b..11cf61cc 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -93,6 +93,10 @@ class Hud: self.menu.append(self.item2) self.item2.connect("activate", self.save_layout) self.item2.show() + self.item3 = gtk.MenuItem('Reposition Stats') + self.menu.append(self.item3) + self.item3.connect("activate", self.reposition_windows) + self.item3.show() self.ebox.connect_object("button-press-event", self.on_button_press, self.menu) self.main_window.show_all() @@ -118,6 +122,10 @@ class Hud: self.main_window.destroy() self.deleted = True + def reposition_windows(self, args): + for w in self.stat_windows: + self.stat_windows[w].window.move(self.stat_windows[w].x, + self.stat_windows[w].y) def save_layout(self, *args): new_layout = [] # todo: have the hud track the poker table's window position regularly, don't forget to update table.x and table.y. @@ -180,7 +188,6 @@ class Hud: self.stats[config.supported_games[self.poker_game].stats[stat].row] \ [config.supported_games[self.poker_game].stats[stat].col] = \ config.supported_games[self.poker_game].stats[stat].stat_name - # self.mucked_window = gtk.Window() # self.m = Mucked.Mucked(self.mucked_window, self.db_connection) # self.mucked_window.show_all() From 56c928ccdc1888d2af956428d98eeea62ecd9e43 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Fri, 7 Nov 2008 20:26:03 +0000 Subject: [PATCH 5/8] p141 - support new PS UTC timestamps --- pyfpdb/fpdb_simple.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index ab442d85..6b532e97 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -817,17 +817,26 @@ def parseHandStartTime(topline, site): topline=topline[0:pos+1]+"0"+topline[pos+1:] counter+=1 if counter==10: break - + + isUTC=False if site=="ftp": pos = topline.find(" ", len(topline)-26)+1 tmp = topline[pos:] #print "year:", tmp[14:18], "month", tmp[19:21], "day", tmp[22:24], "hour", tmp[0:2], "minute", tmp[3:5], "second", tmp[6:8] result = datetime.datetime(int(tmp[14:18]), int(tmp[19:21]), int(tmp[22:24]), int(tmp[0:2]), int(tmp[3:5]), int(tmp[6:8])) elif site=="ps": - tmp=topline[-30:] - #print "parsehandStartTime, tmp:", tmp - pos = tmp.find("-")+2 - tmp = tmp[pos:] + if topline.find("UTC")!=-1: + pos1 = topline.find("-")+2 + pos2 = topline.find("UTC") + tmp=topline[pos1:pos2] + isUTC=True + print "UTC tmp:",tmp + else: + tmp=topline[-30:] + #print "parsehandStartTime, tmp:", tmp + pos = tmp.find("-")+2 + tmp = tmp[pos:] + print "ET tmp:",tmp #Need to match either # 2008/09/07 06:23:14 ET or # 2008/08/17 - 01:14:43 (ET) @@ -837,9 +846,10 @@ def parseHandStartTime(topline, site): else: raise FpdbError("invalid site in parseHandStartTime") - if site=="ftp" or site=="ps": #these use US ET + if (site=="ftp" or site=="ps") and not isUTC: #these use US ET result+=datetime.timedelta(hours=5) + print "parseHandStartTime result:",result return result #end def parseHandStartTime From 28037de7a6c011ab59ba3b8c3c2f15fa335c1218 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 8 Nov 2008 16:58:24 -0500 Subject: [PATCH 6/8] skip the set_opacity statement in windows until figured out --- pyfpdb/Hud.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 11cf61cc..2490ad91 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -349,7 +349,8 @@ class Stat_Window: # font = pango.FontDescription("Sans 8") self.label[r][c].modify_font(font) - self.window.set_opacity(parent.colors['hudopacity']) + if not os.name == 'nt': # seems to be a bug in opacity on windows + self.window.set_opacity(parent.colors['hudopacity']) self.window.realize self.window.move(self.x, self.y) self.window.show_all() From 49151a92bfbb110b3ba1af104a255cfb7177915c Mon Sep 17 00:00:00 2001 From: steffen123 Date: Mon, 10 Nov 2008 02:02:12 +0000 Subject: [PATCH 7/8] p142 - commented tourney summary parsing as it fails on me. this is alpha9 --- packaging/gentoo/fpdb-1.0_alpha9_p142.ebuild | 62 ++++++++++++++++++++ pyfpdb/fpdb.py | 3 +- pyfpdb/fpdb_import.py | 4 +- pyfpdb/fpdb_simple.py | 3 - 4 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 packaging/gentoo/fpdb-1.0_alpha9_p142.ebuild diff --git a/packaging/gentoo/fpdb-1.0_alpha9_p142.ebuild b/packaging/gentoo/fpdb-1.0_alpha9_p142.ebuild new file mode 100644 index 00000000..c55903f3 --- /dev/null +++ b/packaging/gentoo/fpdb-1.0_alpha9_p142.ebuild @@ -0,0 +1,62 @@ +# Copyright 1999-2008 Gentoo Foundation +# Gentoo had nothing to do with the production of this ebuild, but I'm pre-emptively transferring all copyrights (as far as legally possible under my local jurisdiction) to them. +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/games-util/fpdb/fpdb-1.0_alpha8_p137.ebuild,v 1.0 2008/10/17 steffen@sycamoretest.info Exp $ + +NEED_PYTHON=2.3 + +#inherit distutils + +MY_P="fpdb-${PV}" +DESCRIPTION="A database program to track your online poker games" +HOMEPAGE="https://sourceforge.net/projects/fpdb/" +SRC_URI="mirror://sourceforge/fpdb/${MY_P}.tar.bz2" + +LICENSE="AGPL-3" +SLOT="0" +KEYWORDS="~amd64 ~x86" +#note: this should work on other architectures too, please send me your experiences +IUSE="" + +RDEPEND="virtual/mysql + dev-python/mysql-python + >=x11-libs/gtk+-2.10 + dev-python/pygtk + dev-python/numpy + dev-python/matplotlib" + +DEPEND="${RDEPEND}" + +src_install() { + DIRINST="${D}usr/share/games/fpdb/" + mkdir -p "${DIRINST}" + cp -R * "${DIRINST}" || die + + DIRBIN="${D}usr/games/bin/" + mkdir -p "${DIRBIN}" + #echo "pathes" + #echo "${DIRINST}pyfpdb/fpdb.py" + #echo "${DIRBIN}fpdb.py" + #echo + echo "cd /usr/share/games/fpdb/pyfpdb/ && python fpdb.py" > "${DIRBIN}fpdb" || die + chmod 755 "${DIRBIN}fpdb" || die +} + +#src_test() { +#} + +pkg_postinst() { + elog "Fpdb has been installed and can be called by executing /usr/games/bin/fpdb" + elog "You need to perform a couple more steps manually." + elog "Please also make sure you followed instructions from previous emerges, in particular make sure you configured mysql and set a root pw for it" + elog "Now run this command to connect to MySQL: mysql --user=root --password=yourPassword" + elog "In the mysql command line interface you need to type these two lines (make sure you get the ; at the end)" + elog "In the second line replace \"newPassword\" with a password of your choice" + elog "CREATE DATABASE fpdb;" + elog "GRANT ALL PRIVILEGES ON fpdb.* TO 'fpdb'@'localhost' IDENTIFIED BY 'newPassword' WITH GRANT OPTION;" + elog "Finally copy the default config file from ${DIRINST}docs/default.conf to ~/.fpdb/ for every user that is to use fpdb." + elog "You will need to edit the default.conf, in particular you need to replace the password with what you entered in the \"GRANT ALL...\"" + elog "Finally run the GUI and click the menu database -> recreate tables" + elog "That's it! See our webpage at http://fpdb.sourceforge.net for more documentation" + elog " " +} diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index ad4d3f3d..660bf089 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -331,6 +331,7 @@ class fpdb: #print "start of tab_main_help" mh_tab=gtk.Label("""Welcome to Fpdb! For documentation please visit our website at http://fpdb.sourceforge.net/ or check the docs directory in the fpdb folder. +Please note that default.conf is no longer needed nor used, all configuration now happens in HUD_config.xml This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") self.add_and_display_tab(mh_tab, "Help") #end def tab_main_help @@ -362,7 +363,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) - self.window.set_title("Free Poker DB - version: alpha8+, p137 or higher") + self.window.set_title("Free Poker DB - version: alpha9, p142") self.window.set_border_width(1) self.window.set_size_request(1020,400) self.window.set_resizable(True) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index ee70a9d3..3b0fb983 100755 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -174,8 +174,8 @@ class Importer: if firstline.find("Tournament Summary")!=-1: print "TODO: implement importing tournament summaries" - self.faobs = readfile(inputFile) - self.parseTourneyHistory() + #self.faobs = readfile(inputFile) + #self.parseTourneyHistory() return 0 site=fpdb_simple.recogniseSite(firstline) diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 6b532e97..d1b191de 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -830,13 +830,11 @@ def parseHandStartTime(topline, site): pos2 = topline.find("UTC") tmp=topline[pos1:pos2] isUTC=True - print "UTC tmp:",tmp else: tmp=topline[-30:] #print "parsehandStartTime, tmp:", tmp pos = tmp.find("-")+2 tmp = tmp[pos:] - print "ET tmp:",tmp #Need to match either # 2008/09/07 06:23:14 ET or # 2008/08/17 - 01:14:43 (ET) @@ -849,7 +847,6 @@ def parseHandStartTime(topline, site): if (site=="ftp" or site=="ps") and not isUTC: #these use US ET result+=datetime.timedelta(hours=5) - print "parseHandStartTime result:",result return result #end def parseHandStartTime From f38cdab8e076104cc562998ff810d13ccc430eb1 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Mon, 10 Nov 2008 02:21:47 +0000 Subject: [PATCH 8/8] p143 - update title --- pyfpdb/fpdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 660bf089..bec9be78 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -363,7 +363,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) - self.window.set_title("Free Poker DB - version: alpha9, p142") + self.window.set_title("Free Poker DB - version: alpha9+, p143 or higher") self.window.set_border_width(1) self.window.set_size_request(1020,400) self.window.set_resizable(True)