Merge branch 'master' of git://git.assembla.com/fpdboz
This commit is contained in:
commit
6987cf6584
37
pyfpdb/Anonymise.py
Normal file
37
pyfpdb/Anonymise.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import codecs
|
||||||
|
import Options
|
||||||
|
import HandHistoryConverter
|
||||||
|
|
||||||
|
(options, argv) = Options.fpdb_options()
|
||||||
|
|
||||||
|
filter = options.hhc
|
||||||
|
|
||||||
|
filter_name = filter.replace("ToFpdb", "")
|
||||||
|
|
||||||
|
mod = __import__(filter)
|
||||||
|
obj = getattr(mod, filter_name, None)
|
||||||
|
|
||||||
|
hhc = obj(autostart=False)
|
||||||
|
|
||||||
|
if os.path.exists(options.infile):
|
||||||
|
in_fh = codecs.open(options.infile, 'r', "utf8")
|
||||||
|
filecontents = in_fh.read()
|
||||||
|
in_fh.close()
|
||||||
|
else:
|
||||||
|
print "Could not find file %s" % options.infile
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
m = hhc.re_PlayerInfo.finditer(filecontents)
|
||||||
|
|
||||||
|
players = []
|
||||||
|
for a in m:
|
||||||
|
players = players + [a.group('PNAME')]
|
||||||
|
|
||||||
|
uniq = set(players)
|
||||||
|
|
||||||
|
for i, name in enumerate(uniq, 1):
|
||||||
|
filecontents = filecontents.replace(name, 'Player%d' %i)
|
||||||
|
|
||||||
|
print filecontents
|
|
@ -31,6 +31,7 @@ try:
|
||||||
from matplotlib.figure import Figure
|
from matplotlib.figure import Figure
|
||||||
from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
|
from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
|
||||||
from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar
|
from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar
|
||||||
|
from matplotlib.font_manager import FontProperties
|
||||||
from numpy import arange, cumsum
|
from numpy import arange, cumsum
|
||||||
from pylab import *
|
from pylab import *
|
||||||
except ImportError, inst:
|
except ImportError, inst:
|
||||||
|
@ -170,7 +171,7 @@ class GuiGraphViewer (threading.Thread):
|
||||||
|
|
||||||
#Get graph data from DB
|
#Get graph data from DB
|
||||||
starttime = time()
|
starttime = time()
|
||||||
line = self.getRingProfitGraph(playerids, sitenos, limits)
|
(green, blue, red) = self.getRingProfitGraph(playerids, sitenos, limits)
|
||||||
print "Graph generated in: %s" %(time() - starttime)
|
print "Graph generated in: %s" %(time() - starttime)
|
||||||
|
|
||||||
self.ax.set_title("Profit graph for ring games")
|
self.ax.set_title("Profit graph for ring games")
|
||||||
|
@ -179,22 +180,24 @@ class GuiGraphViewer (threading.Thread):
|
||||||
self.ax.set_xlabel("Hands", fontsize = 12)
|
self.ax.set_xlabel("Hands", fontsize = 12)
|
||||||
self.ax.set_ylabel("$", fontsize = 12)
|
self.ax.set_ylabel("$", fontsize = 12)
|
||||||
self.ax.grid(color='g', linestyle=':', linewidth=0.2)
|
self.ax.grid(color='g', linestyle=':', linewidth=0.2)
|
||||||
if line == None or line == []:
|
if green == None or green == []:
|
||||||
|
|
||||||
#TODO: Do something useful like alert user
|
#TODO: Do something useful like alert user
|
||||||
print "No hands returned by graph query"
|
print "No hands returned by graph query"
|
||||||
else:
|
else:
|
||||||
# text = "All Hands, " + sitename + str(name) + "\nProfit: $" + str(line[-1]) + "\nTotal Hands: " + str(len(line))
|
#text = "Profit: $%.2f\nTotal Hands: %d" %(green[-1], len(green))
|
||||||
text = "All Hands, " + "\nProfit: $" + str(line[-1]) + "\nTotal Hands: " + str(len(line))
|
#self.ax.annotate(text,
|
||||||
|
# xy=(10, -10),
|
||||||
self.ax.annotate(text,
|
# xycoords='axes points',
|
||||||
xy=(10, -10),
|
# horizontalalignment='left', verticalalignment='top',
|
||||||
xycoords='axes points',
|
# fontsize=10)
|
||||||
horizontalalignment='left', verticalalignment='top',
|
|
||||||
fontsize=10)
|
|
||||||
|
|
||||||
#Draw plot
|
#Draw plot
|
||||||
self.ax.plot(line,)
|
self.ax.plot(green, color='green', label='Hands: %d\nProfit: $%.2f' %(len(green), green[-1]))
|
||||||
|
self.ax.plot(blue, color='blue', label='Showdown: $%.2f' %(blue[-1]))
|
||||||
|
self.ax.plot(red, color='red', label='Non-showdown: $%.2f' %(red[-1]))
|
||||||
|
self.ax.legend(loc='best', fancybox=True, shadow=True, prop=FontProperties(size='smaller'))
|
||||||
|
|
||||||
|
|
||||||
self.graphBox.add(self.canvas)
|
self.graphBox.add(self.canvas)
|
||||||
self.canvas.show()
|
self.canvas.show()
|
||||||
|
@ -270,9 +273,13 @@ class GuiGraphViewer (threading.Thread):
|
||||||
if winnings == ():
|
if winnings == ():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
y = map(lambda x:float(x[1]), winnings)
|
green = map(lambda x:float(x[1]), winnings)
|
||||||
line = cumsum(y)
|
blue = map(lambda x: float(x[1]) if x[2] == True else 0.0, winnings)
|
||||||
return line/100
|
red = map(lambda x: float(x[1]) if x[2] == False else 0.0, winnings)
|
||||||
|
greenline = cumsum(green)
|
||||||
|
blueline = cumsum(blue)
|
||||||
|
redline = cumsum(red)
|
||||||
|
return (greenline/100, blueline/100, redline/100)
|
||||||
#end of def getRingProfitGraph
|
#end of def getRingProfitGraph
|
||||||
|
|
||||||
def exportGraph (self, widget, data):
|
def exportGraph (self, widget, data):
|
||||||
|
|
|
@ -36,8 +36,11 @@ def fpdb_options():
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Indicates program was restarted with a different path (only allowed once).")
|
help="Indicates program was restarted with a different path (only allowed once).")
|
||||||
parser.add_option("-i", "--infile",
|
parser.add_option("-i", "--infile",
|
||||||
dest="config", default=None,
|
dest="infile", default="Slartibartfast",
|
||||||
help="Input file")
|
help="Input file")
|
||||||
|
parser.add_option("-k", "--konverter",
|
||||||
|
dest="hhc", default="PokerStarsToFpdb",
|
||||||
|
help="Module name for Hand History Converter")
|
||||||
(options, argv) = parser.parse_args()
|
(options, argv) = parser.parse_args()
|
||||||
return (options, argv)
|
return (options, argv)
|
||||||
|
|
||||||
|
|
|
@ -2561,7 +2561,7 @@ class Sql:
|
||||||
# self.query['playerStatsByPosition'] = """ """
|
# self.query['playerStatsByPosition'] = """ """
|
||||||
|
|
||||||
self.query['getRingProfitAllHandsPlayerIdSite'] = """
|
self.query['getRingProfitAllHandsPlayerIdSite'] = """
|
||||||
SELECT hp.handId, hp.totalProfit
|
SELECT hp.handId, hp.totalProfit, hp.sawShowdown
|
||||||
FROM HandsPlayers hp
|
FROM HandsPlayers hp
|
||||||
INNER JOIN Players pl ON (pl.id = hp.playerId)
|
INNER JOIN Players pl ON (pl.id = hp.playerId)
|
||||||
INNER JOIN Hands h ON (h.id = hp.handId)
|
INNER JOIN Hands h ON (h.id = hp.handId)
|
||||||
|
@ -2572,7 +2572,7 @@ class Sql:
|
||||||
AND h.handStart < '<enddate_test>'
|
AND h.handStart < '<enddate_test>'
|
||||||
<limit_test>
|
<limit_test>
|
||||||
AND hp.tourneysPlayersId IS NULL
|
AND hp.tourneysPlayersId IS NULL
|
||||||
GROUP BY h.handStart, hp.handId, hp.totalProfit
|
GROUP BY h.handStart, hp.handId, hp.sawShowdown, hp.totalProfit
|
||||||
ORDER BY h.handStart"""
|
ORDER BY h.handStart"""
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
|
|
|
@ -0,0 +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 ************
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,34 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import BetfairToFpdb
|
import BetfairToFpdb
|
||||||
|
from Hand import *
|
||||||
import py
|
import py
|
||||||
|
|
||||||
|
import Configuration
|
||||||
|
import Database
|
||||||
|
import SQL
|
||||||
|
import fpdb_import
|
||||||
|
|
||||||
def checkGameInfo(hhc, header, info):
|
config = Configuration.Config(file = "HUD_config.test.xml")
|
||||||
assert hhc.determineGameType(header) == info
|
db = Database.Database(config)
|
||||||
|
sql = SQL.Sql(db_server = 'sqlite')
|
||||||
|
|
||||||
def testGameInfo():
|
settings = {}
|
||||||
hhc = BetfairToFpdb.Betfair(autostart=False)
|
settings.update(config.get_db_parameters())
|
||||||
pairs = (
|
settings.update(config.get_tv_parameters())
|
||||||
(u"""***** Betfair Poker Hand History for Game 472386869 *****
|
settings.update(config.get_import_parameters())
|
||||||
NL $0.02/$0.04 Texas Hold'em - Sunday, January 25, 10:10:42 GMT 2009
|
settings.update(config.get_default_paths())
|
||||||
Table Rookie 191 6-max (Real Money)
|
|
||||||
Seat 1 is the button
|
|
||||||
Total number of active players : 6""",
|
|
||||||
{'type':'ring', 'base':"hold", 'category':'holdem', 'limitType':'nl', 'sb':'0.02', 'bb':'0.04', 'currency':'USD'}),
|
|
||||||
)
|
|
||||||
|
|
||||||
for (header, info) in pairs:
|
def testFlopImport():
|
||||||
yield checkGameInfo, hhc, header, info
|
db.recreate_tables()
|
||||||
|
importer = fpdb_import.Importer(False, settings, config)
|
||||||
|
importer.setDropIndexes("don't drop")
|
||||||
|
importer.setFailOnError(True)
|
||||||
|
importer.setThreads(-1)
|
||||||
|
importer.addBulkImportImportFileOrDir(
|
||||||
|
"""regression-test-files/cash/Betfair/Flop/PLO-6max-USD-0.05-0.10-200909.All.in.river.splitpot.txt""", site="Betfair")
|
||||||
|
importer.setCallHud(False)
|
||||||
|
(stored, dups, partial, errs, ttime) = importer.runImport()
|
||||||
|
importer.clearFileList()
|
||||||
|
|
||||||
|
# Should actually do some testing here
|
||||||
|
assert 1 == 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user