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

Conflicts:
	docs/default.conf
This commit is contained in:
eblade 2008-11-10 03:24:05 -05:00
commit 3325538c66
8 changed files with 150 additions and 72 deletions

View File

@ -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

View File

@ -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 " "
}

View File

@ -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

View File

@ -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")

View File

@ -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()
@ -342,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()

View File

@ -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')
@ -323,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
@ -354,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+, p143 or higher")
self.window.set_border_width(1)
self.window.set_size_request(1020,400)
self.window.set_resizable(True)

View File

@ -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:
@ -183,8 +186,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)
@ -304,4 +307,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"

View File

@ -817,17 +817,24 @@ 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
else:
tmp=topline[-30:]
#print "parsehandStartTime, tmp:", tmp
pos = tmp.find("-")+2
tmp = tmp[pos:]
#Need to match either
# 2008/09/07 06:23:14 ET or
# 2008/08/17 - 01:14:43 (ET)
@ -837,7 +844,7 @@ 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)
return result