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

@ -173,26 +173,26 @@ class Hud:
item = gtk.CheckMenuItem(' All Levels')
self.aggMenu.append(item)
item.connect("activate", self.set_aggregation, ('P',10000))
setattr(self, 'h_aggBBmultItem10000', item)
#
setattr(self, 'h_aggBBmultItem10000', item)
#
item = gtk.MenuItem('For #Seats:')
self.aggMenu.append(item)
#
#
item = gtk.CheckMenuItem(' Any Number')
self.aggMenu.append(item)
item.connect("activate", self.set_seats_style, ('P','A'))
setattr(self, 'h_seatsStyleOptionA', item)
#
#
item = gtk.CheckMenuItem(' Custom')
self.aggMenu.append(item)
item.connect("activate", self.set_seats_style, ('P','C'))
setattr(self, 'h_seatsStyleOptionC', item)
#
setattr(self, 'h_seatsStyleOptionC', item)
#
item = gtk.CheckMenuItem(' Exact')
self.aggMenu.append(item)
item.connect("activate", self.set_seats_style, ('P','E'))
setattr(self, 'h_seatsStyleOptionE', item)
#
setattr(self, 'h_seatsStyleOptionE', item)
#
item = gtk.MenuItem('Since:')
self.aggMenu.append(item)
#
@ -242,26 +242,26 @@ class Hud:
item = gtk.CheckMenuItem(' All Levels')
self.aggMenu.append(item)
item.connect("activate", self.set_aggregation, ('O',10000))
setattr(self, 'aggBBmultItem10000', item)
#
setattr(self, 'aggBBmultItem10000', item)
#
item = gtk.MenuItem('For #Seats:')
self.aggMenu.append(item)
#
#
item = gtk.CheckMenuItem(' Any Number')
self.aggMenu.append(item)
item.connect("activate", self.set_seats_style, ('O','A'))
setattr(self, 'seatsStyleOptionA', item)
#
#
item = gtk.CheckMenuItem(' Custom')
self.aggMenu.append(item)
item.connect("activate", self.set_seats_style, ('O','C'))
setattr(self, 'seatsStyleOptionC', item)
#
setattr(self, 'seatsStyleOptionC', item)
#
item = gtk.CheckMenuItem(' Exact')
self.aggMenu.append(item)
item.connect("activate", self.set_seats_style, ('O','E'))
setattr(self, 'seatsStyleOptionE', item)
#
setattr(self, 'seatsStyleOptionE', item)
#
item = gtk.MenuItem('Since:')
self.aggMenu.append(item)
#
@ -358,7 +358,7 @@ class Hud:
def change_max_seats(self, widget):
if self.max != widget.ms:
print 'change_max_seats', widget.ms
#print 'change_max_seats', widget.ms
self.max = widget.ms
try:
self.kill()
@ -402,7 +402,7 @@ class Hud:
else:
param = 'seats_style'
prefix = ''
if style == 'A' and getattr(self, prefix+'seatsStyleOptionA').get_active():
self.hud_params[param] = 'A'
getattr(self, prefix+'seatsStyleOptionC').set_active(False)
@ -678,7 +678,7 @@ class Stat_Window:
return True
def kill_popup(self, popup):
print "remove popup", popup
#print "remove popup", popup
self.popups.remove(popup)
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)
else:
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:
pass
#print "debug - not changing path"
if os.name == 'nt':
import win32api
import win32con
try:
import win32api
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'
@ -63,9 +69,14 @@ if not options.errorsToConsole:
#import logging
import logging, logging.config
import pygtk
pygtk.require('2.0')
import gtk
try:
import pygtk
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
@ -119,7 +130,7 @@ class fpdb:
self.pages.append(new_page)
self.tabs.append(event_box)
self.tab_names.append(new_tab_name)
#self.nb.append_page(new_page, gtk.Label(new_tab_name))
self.nb.append_page(page, event_box)
self.nb_tabs.append(new_tab_name)
@ -139,12 +150,12 @@ class fpdb:
self.nb.set_current_page(tab_no)
def create_custom_tab(self, text, nb):
#create a custom tab for notebook containing a
#create a custom tab for notebook containing a
#label and a button with STOCK_ICON
eventBox = gtk.EventBox()
tabBox = gtk.HBox(False, 2)
tabLabel = gtk.Label(text)
tabBox.pack_start(tabLabel, False)
tabBox.pack_start(tabLabel, False)
eventBox.add(tabBox)
if nb.get_n_pages() > 0:
@ -161,7 +172,7 @@ class fpdb:
return eventBox
def add_icon_to_button(self, button):
iconBox = gtk.HBox(False, 0)
iconBox = gtk.HBox(False, 0)
image = gtk.Image()
image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_SMALL_TOOLBAR)
gtk.Button.set_relief(button, gtk.RELIEF_NONE)
@ -172,8 +183,8 @@ class fpdb:
iconBox.pack_start(image, True, False, 0)
button.add(iconBox)
iconBox.show()
return
return
# Remove a page from the notebook
def remove_tab(self, button, data):
(nb, text) = data
@ -187,7 +198,7 @@ class fpdb:
#print " removing page", page
del self.nb_tabs[page]
nb.remove_page(page)
# Need to refresh the widget --
# Need to refresh the widget --
# This forces the widget to redraw itself.
#nb.queue_draw_area(0,0,-1,-1) needed or not??
@ -200,14 +211,14 @@ class fpdb:
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")
dia = gtk.AboutDialog()
dia.set_name("FPDB")
dia.set_name("Free Poker Database (FPDB)")
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_license("GPL v3")
dia.set_website("http://fpdb.sourceforge.net/")
dia.set_authors("Steffen, Eratosthenes, s0rrow, EricBlade, _mt, and others")
dia.set_program_name("FPDB")
dia.set_authors("Steffen, Eratosthenes, s0rrow, EricBlade, _mt, sqlcoder, Bostik, and others")
dia.set_program_name("Free Poker Database (FPDB)")
dia.run()
dia.destroy()
@ -624,7 +635,7 @@ class fpdb:
self.warning_box("MySQL Server reports: Access denied. Are your permissions set correctly?")
exit()
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)
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 ...")
def window_state_event_cb(self, window, event):
print "window_state_event", event
if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED:
# -20 = GWL_EXSTYLE can't find it in the pywin32 libs
#bits = win32api.GetWindowLong(self.window.window.handle, -20)

View File

@ -106,7 +106,7 @@ class fpdb_db:
except MySQLdb.Error, ex:
if ex.args[0] == 1045:
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])
else:
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 sys
from time import time, strftime, sleep
from time import time, strftime, sleep, clock
import traceback
import math
import datetime
@ -101,6 +101,8 @@ class Importer:
self.NEWIMPORT = Configuration.NEWIMPORT
clock() # init clock in windows
#Set functions
def setCallHud(self, 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]
try:
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?
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.updatedtime[file] = time()
else:
@ -393,7 +400,7 @@ class Importer:
if os.path.isdir(file):
self.addToDirList[file] = [site] + [filter]
return
return (0,0,0,0,0)
conv = None
(stored, duplicates, partial, errors, ttime) = (0, 0, 0, 0, 0)
@ -481,10 +488,13 @@ class Importer:
self.pos_in_file[file] = inputFile.tell()
inputFile.close()
x = clock()
(stored, duplicates, partial, errors, ttime, handsId) = self.import_fpdb_lines(db, self.lines, starttime, file, site, q)
db.commit()
ttime = time() - starttime
y = clock()
ttime = y - x
#ttime = time() - starttime
if q is None:
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
#pipe the Hands.id out to the HUD
# print "fpdb_import: sending hand to hud", handsId, "pipe =", self.caller.pipe_to_hud
self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep)
try:
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:
duplicates += 1
db.rollback()

File diff suppressed because it is too large Load Diff

View File

@ -1,55 +1,55 @@
***** Betfair Poker Hand History for Game 100000000 *****
PL $0.05/$0.10 Omaha - Sunday, October 18, 20:00:00 GMT 2009
Table Death 1 6-max (Real Money)
Seat 2 is the button
Total number of active players : 6
Seat 1: Player6 ( $1 )
Seat 2: Player3 ( $9.38 )
Seat 3: Player2 ( $2.82 )
Seat 4: Player4 ( $4.13 )
Seat 5: Player5 ( $28.77 )
Seat 6: Player1 ( $6.46 )
Player2 posts small blind [$0.05]
Player4 posts big blind [$0.10]
Player6 posts big blind [$0.10]
** Dealing down cards **
Dealt to Player6 [ 7c, 6c, 5h, Jh ]
Player5 folds
Player1 calls [$0.10]
Player6 checks
Player3 calls [$0.10]
Player2 raises to [$0.30]
Player4 calls [$0.20]
Player1 calls [$0.20]
Player6 goes all-in
Player6 raises to [$1]
Player3 calls [$0.90]
Player2 calls [$0.70]
Player4 calls [$0.70]
Player1 calls [$0.70]
** Dealing Flop ** [ 4d, 5d, 6d ]
Player2 checks
Player4 checks
Player1 checks
Player3 checks
** Dealing Turn ** [ 3s ]
Player2 checks
Player4 bets [$0.10]
Player1 calls [$0.10]
Player3 folds
Player2 folds
** Dealing River ** [ 4c ]
Player4 goes all-in
Player4 bets [$3.03]
Player1 calls [$3.03]
** Showdown **
Player6 shows [ 7c, 6c, 5h, Jh ] a straight, Seven to Three
Player4 shows [ 7d, 8c, 3d, 6h ] a straight flush, Seven to Three
Player1 shows [ 3h, 4h, Td, 4s ] four of a kind, Fours
** Hand Conclusion **
Player4 wins $6.26 from side pot #1 with a straight flush, Seven to Three
Player4 wins $4.44 from main pot with a straight flush, Seven to Three
************ Game 100000000 ends ************
***** Betfair Poker Hand History for Game 100000000 *****
PL $0.05/$0.10 Omaha - Sunday, October 18, 20:00:00 GMT 2009
Table Death 1 6-max (Real Money)
Seat 2 is the button
Total number of active players : 6
Seat 1: Player6 ( $1 )
Seat 2: Player3 ( $9.38 )
Seat 3: Player2 ( $2.82 )
Seat 4: Player4 ( $4.13 )
Seat 5: Player5 ( $28.77 )
Seat 6: Player1 ( $6.46 )
Player2 posts small blind [$0.05]
Player4 posts big blind [$0.10]
Player6 posts big blind [$0.10]
** Dealing down cards **
Dealt to Player6 [ 7c, 6c, 5h, Jh ]
Player5 folds
Player1 calls [$0.10]
Player6 checks
Player3 calls [$0.10]
Player2 raises to [$0.30]
Player4 calls [$0.20]
Player1 calls [$0.20]
Player6 goes all-in
Player6 raises to [$1]
Player3 calls [$0.90]
Player2 calls [$0.70]
Player4 calls [$0.70]
Player1 calls [$0.70]
** Dealing Flop ** [ 4d, 5d, 6d ]
Player2 checks
Player4 checks
Player1 checks
Player3 checks
** Dealing Turn ** [ 3s ]
Player2 checks
Player4 bets [$0.10]
Player1 calls [$0.10]
Player3 folds
Player2 folds
** Dealing River ** [ 4c ]
Player4 goes all-in
Player4 bets [$3.03]
Player1 calls [$3.03]
** Showdown **
Player6 shows [ 7c, 6c, 5h, Jh ] a straight, Seven to Three
Player4 shows [ 7d, 8c, 3d, 6h ] a straight flush, Seven to Three
Player1 shows [ 3h, 4h, Td, 4s ] four of a kind, Fours
** Hand Conclusion **
Player4 wins $6.26 from side pot #1 with a straight flush, Seven to Three
Player4 wins $4.44 from main pot with a straight flush, Seven to Three
************ Game 100000000 ends ************