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

This commit is contained in:
Worros 2009-12-07 12:10:56 +08:00
commit 5f67fc8220
7 changed files with 347 additions and 335 deletions

0
pyfpdb/Database.py Executable file → Normal file
View File

View File

@ -358,7 +358,7 @@ class Hud:
def change_max_seats(self, widget): def change_max_seats(self, widget):
if self.max != widget.ms: if self.max != widget.ms:
print 'change_max_seats', widget.ms #print 'change_max_seats', widget.ms
self.max = widget.ms self.max = widget.ms
try: try:
self.kill() self.kill()
@ -678,7 +678,7 @@ class Stat_Window:
return True return True
def kill_popup(self, popup): def kill_popup(self, popup):
print "remove popup", popup #print "remove popup", popup
self.popups.remove(popup) self.popups.remove(popup)
popup.window.destroy() popup.window.destroy()

View File

@ -37,14 +37,20 @@ if os.name == 'nt' and sys.version[0:3] not in ('2.5', '2.6') and '-r' not in sy
os.execvpe('python.exe', ('python.exe', 'fpdb.py', '-r'), os.environ) # first arg is ignored (name of program being run) os.execvpe('python.exe', ('python.exe', 'fpdb.py', '-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"
exit raw_input("Press ENTER to continue.")
exit()
else: else:
pass pass
#print "debug - not changing path" #print "debug - not changing path"
if os.name == 'nt': if os.name == 'nt':
try:
import win32api import win32api
import win32con import win32con
except ImportError:
print "We appear to be running in Windows, but the Windows Python Extensions are not loading. Please install the PYWIN32 package from http://sourceforge.net/projects/pywin32/"
raw_input("Press ENTER to continue.")
exit()
print "Python " + sys.version[0:3] + '...\n' print "Python " + sys.version[0:3] + '...\n'
@ -63,9 +69,14 @@ if not options.errorsToConsole:
#import logging #import logging
import logging, logging.config import logging, logging.config
import pygtk try:
pygtk.require('2.0') import pygtk
import gtk pygtk.require('2.0')
import gtk
except:
print "Unable to load PYGTK modules required for GUI. Please install PyCairo, PyGObject, and PyGTK from www.pygtk.org."
raw_input("Press ENTER to continue.")
exit()
import interlocks import interlocks
@ -200,14 +211,14 @@ class fpdb:
def dia_about(self, widget, data=None): def dia_about(self, widget, data=None):
#self.warning_box("About FPDB:\n\nFPDB was originally created by a guy named Steffen, sometime in 2008, \nand is mostly worked on these days by people named Eratosthenes, s0rrow, _mt, EricBlade, sqlcoder, and other strange people.\n\n", "ABOUT FPDB") #self.warning_box("About FPDB:\n\nFPDB was originally created by a guy named Steffen, sometime in 2008, \nand is mostly worked on these days by people named Eratosthenes, s0rrow, _mt, EricBlade, sqlcoder, and other strange people.\n\n", "ABOUT FPDB")
dia = gtk.AboutDialog() dia = gtk.AboutDialog()
dia.set_name("FPDB") dia.set_name("Free Poker Database (FPDB)")
dia.set_version(VERSION) dia.set_version(VERSION)
dia.set_copyright("2008-2009, Steffen, Eratosthenes, s0rrow, EricBlade, _mt, sqlcoder, and others") dia.set_copyright("2008-2010, Steffen, Eratosthenes, s0rrow, EricBlade, _mt, sqlcoder, Bostik, and others")
dia.set_comments("GTK AboutDialog comments here") dia.set_comments("GTK AboutDialog comments here")
dia.set_license("GPL v3") dia.set_license("GPL v3")
dia.set_website("http://fpdb.sourceforge.net/") dia.set_website("http://fpdb.sourceforge.net/")
dia.set_authors("Steffen, Eratosthenes, s0rrow, EricBlade, _mt, and others") dia.set_authors("Steffen, Eratosthenes, s0rrow, EricBlade, _mt, sqlcoder, Bostik, and others")
dia.set_program_name("FPDB") dia.set_program_name("Free Poker Database (FPDB)")
dia.run() dia.run()
dia.destroy() dia.destroy()
@ -624,7 +635,7 @@ class fpdb:
self.warning_box("MySQL Server reports: Access denied. Are your permissions set correctly?") self.warning_box("MySQL Server reports: Access denied. Are your permissions set correctly?")
exit() exit()
except Exceptions.FpdbMySQLNoDatabase: except Exceptions.FpdbMySQLNoDatabase:
msg = "MySQL client reports: 2002 error. Unable to connect - Please check that the MySQL service has been started" msg = "MySQL client reports: 2002 or 2003 error. Unable to connect - Please check that the MySQL service has been started"
self.warning_box(msg) self.warning_box(msg)
exit exit
@ -819,7 +830,6 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
sys.stderr.write("fpdb starting ...") sys.stderr.write("fpdb starting ...")
def window_state_event_cb(self, window, event): def window_state_event_cb(self, window, event):
print "window_state_event", event
if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED: if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED:
# -20 = GWL_EXSTYLE can't find it in the pywin32 libs # -20 = GWL_EXSTYLE can't find it in the pywin32 libs
#bits = win32api.GetWindowLong(self.window.window.handle, -20) #bits = win32api.GetWindowLong(self.window.window.handle, -20)

View File

@ -106,7 +106,7 @@ class fpdb_db:
except MySQLdb.Error, ex: except MySQLdb.Error, ex:
if ex.args[0] == 1045: if ex.args[0] == 1045:
raise FpdbMySQLAccessDenied(ex.args[0], ex.args[1]) raise FpdbMySQLAccessDenied(ex.args[0], ex.args[1])
elif ex.args[0] == 2002: elif ex.args[0] == 2002 or ex.args[0] == 2003: # 2002 is no unix socket, 2003 is no tcp socket
raise FpdbMySQLNoDatabase(ex.args[0], ex.args[1]) raise FpdbMySQLNoDatabase(ex.args[0], ex.args[1])
else: else:
print "*** WARNING UNKNOWN MYSQL ERROR", ex print "*** WARNING UNKNOWN MYSQL ERROR", ex

View File

@ -21,7 +21,7 @@
import os # todo: remove this once import_dir is in fpdb_import import os # todo: remove this once import_dir is in fpdb_import
import sys import sys
from time import time, strftime, sleep from time import time, strftime, sleep, clock
import traceback import traceback
import math import math
import datetime import datetime
@ -101,6 +101,8 @@ class Importer:
self.NEWIMPORT = Configuration.NEWIMPORT self.NEWIMPORT = Configuration.NEWIMPORT
clock() # init clock in windows
#Set functions #Set functions
def setCallHud(self, value): def setCallHud(self, value):
self.callHud = value self.callHud = value
@ -359,10 +361,15 @@ class Importer:
# print "file",counter," updated", os.path.basename(file), stat_info.st_size, self.updatedsize[file], stat_info.st_mtime, self.updatedtime[file] # print "file",counter," updated", os.path.basename(file), stat_info.st_size, self.updatedsize[file], stat_info.st_mtime, self.updatedtime[file]
try: try:
if not os.path.isdir(file): if not os.path.isdir(file):
self.caller.addText("\n"+file) self.caller.addText("\n"+os.path.basename(file))
except KeyError: # TODO: What error happens here? except KeyError: # TODO: What error happens here?
pass pass
self.import_file_dict(self.database, file, self.filelist[file][0], self.filelist[file][1], None) (stored, duplicates, partial, errors, ttime) = self.import_file_dict(self.database, file, self.filelist[file][0], self.filelist[file][1], None)
try:
if not os.path.isdir(file):
self.caller.addText(" %d stored, %d duplicates, %d partial, %d errors (time = %f)" % (stored, duplicates, partial, errors, ttime))
except KeyError: # TODO: Again, what error happens here? fix when we find out ..
pass
self.updatedsize[file] = stat_info.st_size self.updatedsize[file] = stat_info.st_size
self.updatedtime[file] = time() self.updatedtime[file] = time()
else: else:
@ -393,7 +400,7 @@ class Importer:
if os.path.isdir(file): if os.path.isdir(file):
self.addToDirList[file] = [site] + [filter] self.addToDirList[file] = [site] + [filter]
return return (0,0,0,0,0)
conv = None conv = None
(stored, duplicates, partial, errors, ttime) = (0, 0, 0, 0, 0) (stored, duplicates, partial, errors, ttime) = (0, 0, 0, 0, 0)
@ -481,10 +488,13 @@ class Importer:
self.pos_in_file[file] = inputFile.tell() self.pos_in_file[file] = inputFile.tell()
inputFile.close() inputFile.close()
x = clock()
(stored, duplicates, partial, errors, ttime, handsId) = self.import_fpdb_lines(db, self.lines, starttime, file, site, q) (stored, duplicates, partial, errors, ttime, handsId) = self.import_fpdb_lines(db, self.lines, starttime, file, site, q)
db.commit() db.commit()
ttime = time() - starttime y = clock()
ttime = y - x
#ttime = time() - starttime
if q is None: if q is None:
log.info("Total stored: %(stored)d\tduplicates:%(duplicates)d\terrors:%(errors)d\ttime:%(ttime)s" % locals()) log.info("Total stored: %(stored)d\tduplicates:%(duplicates)d\terrors:%(errors)d\ttime:%(ttime)s" % locals())
@ -563,7 +573,11 @@ class Importer:
#print "call to HUD here. handsId:",handsId #print "call to HUD here. handsId:",handsId
#pipe the Hands.id out to the HUD #pipe the Hands.id out to the HUD
# print "fpdb_import: sending hand to hud", handsId, "pipe =", self.caller.pipe_to_hud # print "fpdb_import: sending hand to hud", handsId, "pipe =", self.caller.pipe_to_hud
try:
self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep) self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep)
except IOError: # hud closed
self.callHud = False
pass # continue import without hud
except Exceptions.DuplicateError: except Exceptions.DuplicateError:
duplicates += 1 duplicates += 1
db.rollback() db.rollback()

View File

@ -1241,38 +1241,34 @@ sure to also change the following storage method and table_viewer.prepare_data i
#calculate saw* values #calculate saw* values
isAllIn = False isAllIn = any(i for i in allIns[0][player])
if any(i for i in allIns[0][player]): if isAllIn or len(action_types[1][player]) > 0:
isAllIn = True
if (len(action_types[1][player])>0 or isAllIn):
myStreet1Seen = True myStreet1Seen = True
if any(i for i in allIns[1][player]): if not isAllIn:
isAllIn = True isAllIn = any(i for i in allIns[1][player])
if (len(action_types[2][player])>0 or isAllIn): elif len(action_types[2][player]) > 0:
if all(actiontype != "fold" for actiontype in action_types[1][player]):
myStreet2Seen = True myStreet2Seen = True
if any(i for i in allIns[2][player]): if not isAllIn:
isAllIn = True isAllAin = any(i for i in allIns[2][player])
if (len(action_types[3][player])>0 or isAllIn): elif len(action_types[3][player]) > 0:
if all(actiontype != "fold" for actiontype in action_types[2][player]):
myStreet3Seen = True myStreet3Seen = True
#print "base:", base #print "base:", base
if base=="hold": if base == "hold":
mySawShowdown = True mySawShowdown = not any(actiontype == "fold" for actiontype in action_types[3][player])
if any(actiontype == "fold" for actiontype in action_types[3][player]):
mySawShowdown = False
else: else:
#print "in else" #print "in else"
if any(i for i in allIns[3][player]): if not isAllIn:
isAllIn = True isAllIn = any(i for i in allIns[3][player])
if (len(action_types[4][player])>0 or isAllIn): elif len(action_types[4][player]) > 0:
#print "in if" #print "in if"
myStreet4Seen = True myStreet4Seen = True
mySawShowdown = True mySawShowdown = not any(actiontype == "fold" for actiontype in action_types[4][player])
if any(actiontype == "fold" for actiontype in action_types[4][player]):
mySawShowdown = False
if myStreet1Seen: if myStreet1Seen:
result['playersAtStreet1'] += 1 result['playersAtStreet1'] += 1
@ -1286,98 +1282,90 @@ sure to also change the following storage method and table_viewer.prepare_data i
result['playersAtShowdown'] += 1 result['playersAtShowdown'] += 1
#flop stuff #flop stuff
street=1 street = 1
if myStreet1Seen: if myStreet1Seen:
if any(actiontype == "bet" for actiontype in action_types[street][player]): myStreet1Aggr = any(actiontype == "bet" for actiontype in action_types[street][player])
myStreet1Aggr = True
myStreet1Calls = action_types[street][player].count('call') myStreet1Calls = action_types[street][player].count('call')
myStreet1Bets = action_types[street][player].count('bet') myStreet1Bets = action_types[street][player].count('bet')
# street1Raises = action_types[street][player].count('raise') bet count includes raises for now # street1Raises = action_types[street][player].count('raise') bet count includes raises for now
result['street1Raises'] += myStreet1Bets result['street1Raises'] += myStreet1Bets
for otherPlayer in xrange(len(player_ids)): for otherPlayer in xrange(len(player_ids)):
if player==otherPlayer: if player == otherPlayer:
pass pass
else: else:
for countOther in xrange(len(action_types[street][otherPlayer])): for countOther in xrange(len(action_types[street][otherPlayer])):
if action_types[street][otherPlayer][countOther]=="bet": if action_types[street][otherPlayer][countOther] == "bet":
myOtherRaisedStreet1=True myOtherRaisedStreet1 = True
for countOtherFold in xrange(len(action_types[street][player])): for countOtherFold in xrange(len(action_types[street][player])):
if action_types[street][player][countOtherFold]=="fold": if action_types[street][player][countOtherFold] == "fold":
myFoldToOtherRaisedStreet1=True myFoldToOtherRaisedStreet1 = True
#turn stuff - copy of flop with different vars #turn stuff - copy of flop with different vars
street=2 street = 2
if myStreet2Seen: if myStreet2Seen:
if any(actiontype == "bet" for actiontype in action_types[street][player]): myStreet2Aggr = any(actiontype == "bet" for actiontype in action_types[street][player])
myStreet2Aggr = True
myStreet2Calls = action_types[street][player].count('call') myStreet2Calls = action_types[street][player].count('call')
myStreet2Bets = action_types[street][player].count('bet') myStreet2Bets = action_types[street][player].count('bet')
# street2Raises = action_types[street][player].count('raise') bet count includes raises for now # street2Raises = action_types[street][player].count('raise') bet count includes raises for now
result['street2Raises'] += myStreet2Bets result['street2Raises'] += myStreet2Bets
for otherPlayer in xrange(len(player_ids)): for otherPlayer in xrange(len(player_ids)):
if player==otherPlayer: if player == otherPlayer:
pass pass
else: else:
for countOther in xrange(len(action_types[street][otherPlayer])): for countOther in xrange(len(action_types[street][otherPlayer])):
if action_types[street][otherPlayer][countOther]=="bet": if action_types[street][otherPlayer][countOther] == "bet":
myOtherRaisedStreet2=True myOtherRaisedStreet2 = True
for countOtherFold in xrange(len(action_types[street][player])): for countOtherFold in xrange(len(action_types[street][player])):
if action_types[street][player][countOtherFold]=="fold": if action_types[street][player][countOtherFold] == "fold":
myFoldToOtherRaisedStreet2=True myFoldToOtherRaisedStreet2 = True
#river stuff - copy of flop with different vars #river stuff - copy of flop with different vars
street=3 street = 3
if myStreet3Seen: if myStreet3Seen:
if any(actiontype == "bet" for actiontype in action_types[street][player]): myStreet3Aggr = any(actiontype == "bet" for actiontype in action_types[street][player])
myStreet3Aggr = True
myStreet3Calls = action_types[street][player].count('call') myStreet3Calls = action_types[street][player].count('call')
myStreet3Bets = action_types[street][player].count('bet') myStreet3Bets = action_types[street][player].count('bet')
# street3Raises = action_types[street][player].count('raise') bet count includes raises for now # street3Raises = action_types[street][player].count('raise') bet count includes raises for now
result['street3Raises'] += myStreet3Bets result['street3Raises'] += myStreet3Bets
for otherPlayer in xrange(len(player_ids)): for otherPlayer in xrange(len(player_ids)):
if player==otherPlayer: if player == otherPlayer:
pass pass
else: else:
for countOther in xrange(len(action_types[street][otherPlayer])): for countOther in xrange(len(action_types[street][otherPlayer])):
if action_types[street][otherPlayer][countOther]=="bet": if action_types[street][otherPlayer][countOther] == "bet":
myOtherRaisedStreet3=True myOtherRaisedStreet3 = True
for countOtherFold in xrange(len(action_types[street][player])): for countOtherFold in xrange(len(action_types[street][player])):
if action_types[street][player][countOtherFold]=="fold": if action_types[street][player][countOtherFold] == "fold":
myFoldToOtherRaisedStreet3=True myFoldToOtherRaisedStreet3 = True
#stud river stuff - copy of flop with different vars #stud river stuff - copy of flop with different vars
street=4 street = 4
if myStreet4Seen: if myStreet4Seen:
if any(actiontype == "bet" for actiontype in action_types[street][player]): myStreet4Aggr = any(actiontype == "bet" for actiontype in action_types[street][player])
myStreet4Aggr=True
myStreet4Calls = action_types[street][player].count('call') myStreet4Calls = action_types[street][player].count('call')
myStreet4Bets = action_types[street][player].count('bet') myStreet4Bets = action_types[street][player].count('bet')
# street4Raises = action_types[street][player].count('raise') bet count includes raises for now # street4Raises = action_types[street][player].count('raise') bet count includes raises for now
result['street4Raises'] += myStreet4Bets result['street4Raises'] += myStreet4Bets
for otherPlayer in xrange(len(player_ids)): for otherPlayer in xrange(len(player_ids)):
if player==otherPlayer: if player == otherPlayer:
pass pass
else: else:
for countOther in xrange(len(action_types[street][otherPlayer])): for countOther in xrange(len(action_types[street][otherPlayer])):
if action_types[street][otherPlayer][countOther]=="bet": if action_types[street][otherPlayer][countOther] == "bet":
myOtherRaisedStreet4=True myOtherRaisedStreet4 = True
for countOtherFold in xrange(len(action_types[street][player])): for countOtherFold in xrange(len(action_types[street][player])):
if action_types[street][player][countOtherFold]=="fold": if action_types[street][player][countOtherFold] == "fold":
myFoldToOtherRaisedStreet4=True myFoldToOtherRaisedStreet4 = True
if winnings[player] != 0: if winnings[player] != 0:
if myStreet1Seen: if myStreet1Seen:
myWonWhenSeenStreet1 = winnings[player] / float(totalWinnings) myWonWhenSeenStreet1 = winnings[player] / float(totalWinnings)
if mySawShowdown: if mySawShowdown:
myWonAtSD=myWonWhenSeenStreet1 myWonAtSD = myWonWhenSeenStreet1
#add each value to the appropriate array #add each value to the appropriate array
street0VPI.append(myStreet0VPI) street0VPI.append(myStreet0VPI)