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

This commit is contained in:
sqlcoder 2009-10-15 23:02:57 +01:00
commit 7bd388613d
8 changed files with 247 additions and 155 deletions

View File

@ -282,6 +282,19 @@ class HudUI:
def __init__(self, node): def __init__(self, node):
self.node = node self.node = node
self.label = node.getAttribute('label') self.label = node.getAttribute('label')
#
self.aggregate_ring = fix_tf(node.getAttribute('aggregate_ring_game_stats'))
self.aggregate_tour = fix_tf(node.getAttribute('aggregate_tourney_stats'))
self.hud_style = node.getAttribute('stat_aggregation_range')
self.hud_days = node.getAttribute('aggregation_days')
self.agg_bb_mult = node.getAttribute('aggregation_level_multiplier')
#
self.h_aggregate_ring = fix_tf(node.getAttribute('aggregate_hero_ring_game_stats'))
self.h_aggregate_tour = fix_tf(node.getAttribute('aggregate_hero_tourney_stats'))
self.h_hud_style = node.getAttribute('hero_stat_aggregation_range')
self.h_hud_days = node.getAttribute('hero_aggregation_days')
self.h_agg_bb_mult = node.getAttribute('hero_aggregation_level_multiplier')
def __str__(self): def __str__(self):
return " label = %s\n" % self.label return " label = %s\n" % self.label
@ -629,6 +642,7 @@ class Config:
# Allow to change the menu appearance # Allow to change the menu appearance
def get_hud_ui_parameters(self): def get_hud_ui_parameters(self):
hui = {} hui = {}
default_text = 'FPDB Menu - Right click\nLeft-Drag to Move' default_text = 'FPDB Menu - Right click\nLeft-Drag to Move'
try: try:
hui['label'] = self.ui.label hui['label'] = self.ui.label
@ -636,6 +650,39 @@ class Config:
hui['label'] = default_text hui['label'] = default_text
except: except:
hui['label'] = default_text hui['label'] = default_text
try: hui['aggregate_ring'] = self.ui.aggregate_ring
except: hui['aggregate_ring'] = False
try: hui['aggregate_tour'] = self.ui.aggregate_tour
except: hui['aggregate_tour'] = True
try: hui['hud_style'] = self.ui.hud_style
except: hui['hud_style'] = 'A'
try: hui['hud_days'] = int(self.ui.hud_days)
except: hui['hud_days'] = 90
try: hui['agg_bb_mult'] = self.ui.agg_bb_mult
except: hui['agg_bb_mult'] = 1
# Hero specific
try: hui['h_aggregate_ring'] = self.ui.h_aggregate_ring
except: hui['h_aggregate_ring'] = False
try: hui['h_aggregate_tour'] = self.ui.h_aggregate_tour
except: hui['h_aggregate_tour'] = True
try: hui['h_hud_style'] = self.ui.h_hud_style
except: hui['h_hud_style'] = 'S'
try: hui['h_hud_days'] = int(self.ui.h_hud_days)
except: hui['h_hud_days'] = 30
try: hui['h_agg_bb_mult'] = self.ui.h_agg_bb_mult
except: hui['h_agg_bb_mult'] = 1
return hui return hui

View File

@ -1386,41 +1386,7 @@ class Database:
def storeHand(self, p): def storeHand(self, p):
#stores into table hands: #stores into table hands:
q = """INSERT INTO Hands ( q = self.sql.query['store_hand']
tablename,
gametypeid,
sitehandno,
handstart,
importtime,
seats,
maxseats,
texture,
playersVpi,
boardcard1,
boardcard2,
boardcard3,
boardcard4,
boardcard5,
playersAtStreet1,
playersAtStreet2,
playersAtStreet3,
playersAtStreet4,
playersAtShowdown,
street0Raises,
street1Raises,
street2Raises,
street3Raises,
street4Raises,
street1Pot,
street2Pot,
street3Pot,
street4Pot,
showdownPot
)
VALUES
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, %s, %s, %s)"""
q = q.replace('%s', self.sql.query['placeholder']) q = q.replace('%s', self.sql.query['placeholder'])
@ -1455,19 +1421,40 @@ class Database:
p['street4Pot'], p['street4Pot'],
p['showdownPot'] p['showdownPot']
)) ))
#return getLastInsertId(backend, conn, cursor) return self.get_last_insert_id(self.cursor)
# def storeHand # def storeHand
def storeHandsPlayers(self, hid, pid, p): def storeHandsPlayers(self, hid, pids, pdata):
#print "DEBUG: %s %s %s" %(hid, pids, pdata)
inserts = []
for p in pdata:
inserts.append( (hid,
pids[p],
pdata[p]['startCash'],
pdata[p]['seatNo'],
pdata[p]['street0Aggr'],
pdata[p]['street1Aggr'],
pdata[p]['street2Aggr'],
pdata[p]['street3Aggr'],
pdata[p]['street4Aggr']
) )
q = """INSERT INTO HandsPlayers ( q = """INSERT INTO HandsPlayers (
handId, handId,
playerId playerId,
startCash,
seatNo,
street0Aggr,
street1Aggr,
street2Aggr,
street3Aggr,
street4Aggr
) )
VALUES ( VALUES (
%s, %s %s, %s, %s, %s, %s,
%s, %s, %s, %s
)""" )"""
# startCash,
# position, # position,
# tourneyTypeId, # tourneyTypeId,
# card1, # card1,
@ -1477,10 +1464,8 @@ class Database:
# startCards, # startCards,
# winnings, # winnings,
# rake, # rake,
# seatNo,
# totalProfit, # totalProfit,
# street0VPI, # street0VPI,
# street0Aggr,
# street0_3BChance, # street0_3BChance,
# street0_3BDone, # street0_3BDone,
# street1Seen, # street1Seen,
@ -1488,10 +1473,6 @@ class Database:
# street3Seen, # street3Seen,
# street4Seen, # street4Seen,
# sawShowdown, # sawShowdown,
# street1Aggr,
# street2Aggr,
# street3Aggr,
# street4Aggr,
# otherRaisedStreet1, # otherRaisedStreet1,
# otherRaisedStreet2, # otherRaisedStreet2,
# otherRaisedStreet3, # otherRaisedStreet3,
@ -1545,85 +1526,8 @@ class Database:
q = q.replace('%s', self.sql.query['placeholder']) q = q.replace('%s', self.sql.query['placeholder'])
self.cursor.execute(q, ( #print "DEBUG: inserts: %s" %inserts
hid, self.cursor.executemany(q, inserts)
pid
))
# startCash,
# position,
# tourneyTypeId,
# card1,
# card2,
# card3,
# card4,
# startCards,
# winnings,
# rake,
# seatNo,
# totalProfit,
# street0VPI,
# street0Aggr,
# street0_3BChance,
# street0_3BDone,
# street1Seen,
# street2Seen,
# street3Seen,
# street4Seen,
# sawShowdown,
# street1Aggr,
# street2Aggr,
# street3Aggr,
# street4Aggr,
# otherRaisedStreet1,
# otherRaisedStreet2,
# otherRaisedStreet3,
# otherRaisedStreet4,
# foldToOtherRaisedStreet1,
# foldToOtherRaisedStreet2,
# foldToOtherRaisedStreet3,
# foldToOtherRaisedStreet4,
# wonWhenSeenStreet1,
# wonAtSD,
# stealAttemptChance,
# stealAttempted,
# foldBbToStealChance,
# foldedBbToSteal,
# foldSbToStealChance,
# foldedSbToSteal,
# street1CBChance,
# street1CBDone,
# street2CBChance,
# street2CBDone,
# street3CBChance,
# street3CBDone,
# street4CBChance,
# street4CBDone,
# foldToStreet1CBChance,
# foldToStreet1CBDone,
# foldToStreet2CBChance,
# foldToStreet2CBDone,
# foldToStreet3CBChance,
# foldToStreet3CBDone,
# foldToStreet4CBChance,
# foldToStreet4CBDone,
# street1CheckCallRaiseChance,
# street1CheckCallRaiseDone,
# street2CheckCallRaiseChance,
# street2CheckCallRaiseDone,
# street3CheckCallRaiseChance,
# street3CheckCallRaiseDone,
# street4CheckCallRaiseChance,
# street4CheckCallRaiseDone,
# street0Calls,
# street1Calls,
# street2Calls,
# street3Calls,
# street4Calls,
# street0Bets,
# street1Bets,
# street2Bets,
# street3Bets,
# street4Bets
def storeHudCacheNew(self, gid, pid, hc): def storeHudCacheNew(self, gid, pid, hc):
q = """INSERT INTO HudCache ( q = """INSERT INTO HudCache (

View File

@ -29,6 +29,8 @@ class DerivedStats():
for player in hand.players: for player in hand.players:
self.handsplayers[player[1]] = {} self.handsplayers[player[1]] = {}
#Init vars that may not be used, but still need to be inserted.
self.handsplayers[player[1]]['street4Aggr'] = False
self.assembleHands(self.hand) self.assembleHands(self.hand)
self.assembleHandsPlayers(self.hand) self.assembleHandsPlayers(self.hand)
@ -39,6 +41,9 @@ class DerivedStats():
def getHands(self): def getHands(self):
return self.hands return self.hands
def getHandsPlayers(self):
return self.handsplayers
def assembleHands(self, hand): def assembleHands(self, hand):
self.hands['tableName'] = hand.tablename self.hands['tableName'] = hand.tablename
self.hands['siteHandNo'] = hand.handid self.hands['siteHandNo'] = hand.handid
@ -77,10 +82,15 @@ class DerivedStats():
# commentTs DATETIME # commentTs DATETIME
def assembleHandsPlayers(self, hand): def assembleHandsPlayers(self, hand):
self.vpip(self.hand) #hand.players = [[seat, name, chips],[seat, name, chips]]
for player in hand.players:
self.handsplayers[player[1]]['seatNo'] = player[0]
self.handsplayers[player[1]]['startCash'] = player[2]
for i, street in enumerate(hand.actionStreets[1:]): for i, street in enumerate(hand.actionStreets[1:]):
self.aggr(self.hand, i) self.aggr(self.hand, i)
def assembleHudCache(self, hand): def assembleHudCache(self, hand):
# # def generateHudCacheData(player_ids, base, category, action_types, allIns, actionTypeByNo # # def generateHudCacheData(player_ids, base, category, action_types, allIns, actionTypeByNo
# # ,winnings, totalWinnings, positions, actionTypes, actionAmounts, antes): # # ,winnings, totalWinnings, positions, actionTypes, actionAmounts, antes):
@ -777,20 +787,22 @@ class DerivedStats():
if act[1] in ('calls','bets', 'raises'): if act[1] in ('calls','bets', 'raises'):
vpipers.add(act[0]) vpipers.add(act[0])
#for player in hand.players:
# print "DEBUG: '%s' '%s' '%s'" %(player, player[1], vpipers)
# if player[1] in vpipers:
# self.handsplayers[player[1]]['vpip'] = True
# else:
# self.handsplayers[player[1]]['vpip'] = False
self.hands['playersVpi'] = len(vpipers) self.hands['playersVpi'] = len(vpipers)
for player in hand.players:
if player[1] in vpipers:
self.handsplayers[player[1]]['vpip'] = True
else:
self.handsplayers[player[1]]['vpip'] = False
def playersAtStreetX(self, hand): def playersAtStreetX(self, hand):
""" playersAtStreet1 SMALLINT NOT NULL, /* num of players seeing flop/street4/draw1 */""" """ playersAtStreet1 SMALLINT NOT NULL, /* num of players seeing flop/street4/draw1 */"""
# self.actions[street] is a list of all actions in a tuple, contining the player name first # self.actions[street] is a list of all actions in a tuple, contining the player name first
# [ (player, action, ....), (player2, action, ...) ] # [ (player, action, ....), (player2, action, ...) ]
# The number of unique players in the list per street gives the value for playersAtStreetXXX # The number of unique players in the list per street gives the value for playersAtStreetXXX
# FIXME?? - This isn't couting people that are all in - at least showdown needs to reflect this
self.hands['playersAtStreet1'] = 0 self.hands['playersAtStreet1'] = 0
self.hands['playersAtStreet2'] = 0 self.hands['playersAtStreet2'] = 0
self.hands['playersAtStreet3'] = 0 self.hands['playersAtStreet3'] = 0

View File

@ -40,21 +40,6 @@ class GuiBulkImport():
# CONFIGURATION - update these as preferred: # CONFIGURATION - update these as preferred:
allowThreads = True # set to True to try out the threads field allowThreads = True # set to True to try out the threads field
# not used
def import_dir(self):
"""imports a directory, non-recursive. todo: move this to fpdb_import so CLI can use it"""
self.path = self.inputFile
self.importer.addImportDirectory(self.path)
self.importer.setCallHud(False)
starttime = time()
if not self.importer.settings['threads'] > 1:
(stored, dups, partial, errs, ttime) = self.importer.runImport()
print 'GuiBulkImport.import_dir done: Stored: %d Duplicates: %d Partial: %d Errors: %d in %s seconds - %d/sec'\
% (stored, dups, partial, errs, ttime, stored / ttime)
else:
self.importer.RunImportThreaded()
def dopulse(self): def dopulse(self):
self.progressbar.pulse() self.progressbar.pulse()
return True return True
@ -77,7 +62,7 @@ class GuiBulkImport():
self.timer = gobject.timeout_add(100, self.dopulse) self.timer = gobject.timeout_add(100, self.dopulse)
# get the dir to import from the chooser # get the dir to import from the chooser
self.inputFile = self.chooser.get_filename() selected = self.chooser.get_filenames()
# get the import settings from the gui and save in the importer # get the import settings from the gui and save in the importer
self.importer.setHandCount(int(self.spin_hands.get_text())) self.importer.setHandCount(int(self.spin_hands.get_text()))
@ -103,7 +88,8 @@ class GuiBulkImport():
self.importer.setDropHudCache("auto") self.importer.setDropHudCache("auto")
sitename = self.cbfilter.get_model()[self.cbfilter.get_active()][0] sitename = self.cbfilter.get_model()[self.cbfilter.get_active()][0]
self.importer.addBulkImportImportFileOrDir(self.inputFile, site = sitename) for selection in selected:
self.importer.addBulkImportImportFileOrDir(selection, site = sitename)
self.importer.setCallHud(False) self.importer.setCallHud(False)
starttime = time() starttime = time()
# try: # try:
@ -151,6 +137,7 @@ class GuiBulkImport():
self.chooser = gtk.FileChooserWidget() self.chooser = gtk.FileChooserWidget()
self.chooser.set_filename(self.settings['bulkImport-defaultPath']) self.chooser.set_filename(self.settings['bulkImport-defaultPath'])
self.chooser.set_select_multiple(True)
self.vbox.add(self.chooser) self.vbox.add(self.chooser)
self.chooser.show() self.chooser.show()
@ -317,8 +304,20 @@ def main(argv=None):
help="If this option is passed it quits when it encounters any error") help="If this option is passed it quits when it encounters any error")
parser.add_option("-m", "--minPrint", "--status", dest="minPrint", default="0", type="int", parser.add_option("-m", "--minPrint", "--status", dest="minPrint", default="0", type="int",
help="How often to print a one-line status report (0 (default) means never)") help="How often to print a one-line status report (0 (default) means never)")
parser.add_option("-u", "--usage", action="store_true", dest="usage", default=False,
help="Print some useful one liners")
(options, sys.argv) = parser.parse_args(args = argv) (options, sys.argv) = parser.parse_args(args = argv)
if options.usage == True:
#Print usage examples and exit
print "USAGE:"
print 'PokerStars converter: ./GuiBulkImport -c PokerStars -f filename'
print 'Full Tilt converter: ./GuiBulkImport -c "Full Tilt Poker" -f filename'
print "Everleaf converter: ./GuiBulkImport -c Everleaf -f filename"
print "Absolute converter: ./GuiBulkImport -c Absolute -f filename"
print "PartyPoker converter: ./GuiBulkImport -c PartyPoker -f filename"
sys.exit(0)
config = Configuration.Config() config = Configuration.Config()
settings = {} settings = {}
@ -350,8 +349,10 @@ def main(argv=None):
importer.setThreads(-1) importer.setThreads(-1)
importer.addBulkImportImportFileOrDir(os.path.expanduser(options.filename), site=options.filtername) importer.addBulkImportImportFileOrDir(os.path.expanduser(options.filename), site=options.filtername)
importer.setCallHud(False) importer.setCallHud(False)
importer.runImport() (stored, dups, partial, errs, ttime) = importer.runImport()
importer.clearFileList() importer.clearFileList()
print 'GuiBulkImport done: Stored: %d \tDuplicates: %d \tPartial: %d \tErrors: %d in %s seconds - %.0f/sec'\
% (stored, dups, partial, errs, ttime, (stored+0.0) / ttime)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -4,8 +4,97 @@
<import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True"></import> <import callFpdbHud = "True" interval = "10" fastStoreHudCache="False" hhArchiveBase="~/.fpdb/HandHistories/" saveActions="True"></import>
<hud_ui label="FPDB Menu - Right-click
Left-Drag to Move" /> <!-- These values need some explaining
aggregate_ring_game_stats :
- True/False
- if set to True, includes data from other blind levels
- defaults to False
aggregate_tourney_stats :
- True/False
- if set to True, includes data from other blind levels
- defaults to True
stat_aggregation_range :
- A/S/T
- if set to A, includes stats from all time
- if set to S, includes stats from current sessions
- if set to T, includes stats from last N days; set value in hud_days
- defaults to A
aggregation_days :
- a numeric value
- if hud_style is set to 'T', this value tells how many days are
included in the stat calculation
- defaults to 90
- value not used by default, as depends on hud_style setting
aggregation_level_multiplier :
- float value
- defines how many blind levels are used for aggregation
- the logic is weird, at best
- if value is 100, almost all levels are included
- if value is 2.1, levels from half to double the current blind
level are included
- if value it 1, no aggregation is performed
- defaults to 1
The following values define how hero's stats are done
aggregate_hero_ring_game_stats :
- True/False
- if set to True, hero's data is calculated over multiple blind levels
- defaults to False
aggregate_hero_tourney_stats :
- True/False
- if set to True, hero's data is calculated over multiple blind levels
- defaults to False
hero_stat_aggregation_range :
- A/S/T
- if set to A, includes stats from all time
- if set to S, includes stats from current sessions
- if set to T, includes stats from last N days; set value in hud_days
- defaults to S
hero_aggregation_days :
- a numeric value
- if hero_stat_aggregation_range is set to 'T', this value tells
how many days are included in the stat calculation
- defaults to 30
- value not used by default, as depends on hud_style setting
hero_aggregation_level_multiplier :
- float value
- defines how many blind levels are used for aggregation
- the logic is weird, at best
- if value is 100, almost all levels are included
- if value is 2.1, levels from half to double the current blind
level are included
- if value it 1, no aggregation is performed
- defaults to 1
-->
<hud_ui
aggregate_ring_game_stats="False"
aggregate_tourney_stats="False"
stat_aggregation_range="A"
aggregation_days="90"
aggregation_level_multiplier="1"
aggregate_hero_ring_game_stats="False"
aggregate_hero_tourney_stats="True"
hero_stat_aggregation_range="S"
hero_aggregation_days="30"
hero_aggregation_level_multiplier="1"
label="FPDB Menu - Right-click
Left-Drag to Move"
/>
<supported_sites> <supported_sites>

View File

@ -93,7 +93,7 @@ class HUD_main(object):
self.db_name = db_name self.db_name = db_name
self.config = Configuration.Config(file=options.config, dbname=options.dbname) self.config = Configuration.Config(file=options.config, dbname=options.dbname)
self.hud_dict = {} self.hud_dict = {}
self.hud_params = def_hud_params self.hud_params = self.config.get_hud_ui_parameters()
# a thread to read stdin # a thread to read stdin
gobject.threads_init() # this is required gobject.threads_init() # this is required

View File

@ -205,14 +205,14 @@ db: a connected fpdb_db object"""
#Gametypes #Gametypes
gtid = db.getGameTypeId(self.siteId, self.gametype) gtid = db.getGameTypeId(self.siteId, self.gametype)
self.stats.assembleHands(self) self.stats.getStats(self)
##### #####
# End prep functions # End prep functions
##### #####
# HudCache data to come from DerivedStats class
# HandsActions - all actions for all players for all streets - self.actions # HandsActions - all actions for all players for all streets - self.actions
# HudCache data can be generated from HandsActions (HandsPlayers?)
# Hands - Summary information of hand indexed by handId - gameinfo # Hands - Summary information of hand indexed by handId - gameinfo
hh = self.stats.getHands() hh = self.stats.getHands()
@ -223,6 +223,7 @@ db: a connected fpdb_db object"""
#print hh #print hh
handid = db.storeHand(hh) handid = db.storeHand(hh)
# HandsPlayers - ? ... Do we fix winnings? # HandsPlayers - ? ... Do we fix winnings?
db.storeHandsPlayers(handid, sqlids, self.stats.getHandsPlayers())
# Tourneys ? # Tourneys ?
# TourneysPlayers # TourneysPlayers

View File

@ -3110,6 +3110,44 @@ class Sql:
self.query['handsPlayersTTypeId_joiner'] = " OR TourneysPlayersId+0=" self.query['handsPlayersTTypeId_joiner'] = " OR TourneysPlayersId+0="
self.query['handsPlayersTTypeId_joiner_id'] = " OR id=" self.query['handsPlayersTTypeId_joiner_id'] = " OR id="
self.query['store_hand'] = """INSERT INTO Hands (
tablename,
gametypeid,
sitehandno,
handstart,
importtime,
seats,
maxseats,
texture,
playersVpi,
boardcard1,
boardcard2,
boardcard3,
boardcard4,
boardcard5,
playersAtStreet1,
playersAtStreet2,
playersAtStreet3,
playersAtStreet4,
playersAtShowdown,
street0Raises,
street1Raises,
street2Raises,
street3Raises,
street4Raises,
street1Pot,
street2Pot,
street3Pot,
street4Pot,
showdownPot
)
VALUES
(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s, %s, %s, %s, %s, %s, %s)"""
if db_server == 'mysql': if db_server == 'mysql':