diff --git a/pyfpdb/Configuration.py b/pyfpdb/Configuration.py
index 89f4fb29..924d6584 100755
--- a/pyfpdb/Configuration.py
+++ b/pyfpdb/Configuration.py
@@ -282,6 +282,19 @@ class HudUI:
def __init__(self, node):
self.node = node
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):
return " label = %s\n" % self.label
@@ -629,6 +642,7 @@ class Config:
# Allow to change the menu appearance
def get_hud_ui_parameters(self):
hui = {}
+
default_text = 'FPDB Menu - Right click\nLeft-Drag to Move'
try:
hui['label'] = self.ui.label
@@ -636,6 +650,39 @@ class Config:
hui['label'] = default_text
except:
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
diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py
index 4a0f2e17..d25b309c 100755
--- a/pyfpdb/Database.py
+++ b/pyfpdb/Database.py
@@ -1386,41 +1386,7 @@ class Database:
def storeHand(self, p):
#stores into table hands:
- q = """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)"""
+ q = self.sql.query['store_hand']
q = q.replace('%s', self.sql.query['placeholder'])
@@ -1455,19 +1421,40 @@ class Database:
p['street4Pot'],
p['showdownPot']
))
- #return getLastInsertId(backend, conn, cursor)
+ return self.get_last_insert_id(self.cursor)
# 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 (
handId,
- playerId
+ playerId,
+ startCash,
+ seatNo,
+ street0Aggr,
+ street1Aggr,
+ street2Aggr,
+ street3Aggr,
+ street4Aggr
)
VALUES (
- %s, %s
+ %s, %s, %s, %s, %s,
+ %s, %s, %s, %s
)"""
-# startCash,
# position,
# tourneyTypeId,
# card1,
@@ -1477,10 +1464,8 @@ class Database:
# startCards,
# winnings,
# rake,
-# seatNo,
# totalProfit,
# street0VPI,
-# street0Aggr,
# street0_3BChance,
# street0_3BDone,
# street1Seen,
@@ -1488,10 +1473,6 @@ class Database:
# street3Seen,
# street4Seen,
# sawShowdown,
-# street1Aggr,
-# street2Aggr,
-# street3Aggr,
-# street4Aggr,
# otherRaisedStreet1,
# otherRaisedStreet2,
# otherRaisedStreet3,
@@ -1545,85 +1526,8 @@ class Database:
q = q.replace('%s', self.sql.query['placeholder'])
- self.cursor.execute(q, (
- hid,
- 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
+ #print "DEBUG: inserts: %s" %inserts
+ self.cursor.executemany(q, inserts)
def storeHudCacheNew(self, gid, pid, hc):
q = """INSERT INTO HudCache (
diff --git a/pyfpdb/DerivedStats.py b/pyfpdb/DerivedStats.py
index 315ae707..106bd038 100644
--- a/pyfpdb/DerivedStats.py
+++ b/pyfpdb/DerivedStats.py
@@ -29,6 +29,8 @@ class DerivedStats():
for player in hand.players:
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.assembleHandsPlayers(self.hand)
@@ -39,6 +41,9 @@ class DerivedStats():
def getHands(self):
return self.hands
+ def getHandsPlayers(self):
+ return self.handsplayers
+
def assembleHands(self, hand):
self.hands['tableName'] = hand.tablename
self.hands['siteHandNo'] = hand.handid
@@ -77,10 +82,15 @@ class DerivedStats():
# commentTs DATETIME
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:]):
self.aggr(self.hand, i)
+
def assembleHudCache(self, hand):
# # def generateHudCacheData(player_ids, base, category, action_types, allIns, actionTypeByNo
# # ,winnings, totalWinnings, positions, actionTypes, actionAmounts, antes):
@@ -777,20 +787,22 @@ class DerivedStats():
if act[1] in ('calls','bets', 'raises'):
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)
+ 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):
""" 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
# [ (player, action, ....), (player2, action, ...) ]
# 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['playersAtStreet2'] = 0
self.hands['playersAtStreet3'] = 0
diff --git a/pyfpdb/GuiBulkImport.py b/pyfpdb/GuiBulkImport.py
index 21f9e050..9cb54d50 100755
--- a/pyfpdb/GuiBulkImport.py
+++ b/pyfpdb/GuiBulkImport.py
@@ -40,21 +40,6 @@ class GuiBulkImport():
# CONFIGURATION - update these as preferred:
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):
self.progressbar.pulse()
return True
@@ -77,7 +62,7 @@ class GuiBulkImport():
self.timer = gobject.timeout_add(100, self.dopulse)
# 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
self.importer.setHandCount(int(self.spin_hands.get_text()))
@@ -103,7 +88,8 @@ class GuiBulkImport():
self.importer.setDropHudCache("auto")
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)
starttime = time()
# try:
@@ -151,6 +137,7 @@ class GuiBulkImport():
self.chooser = gtk.FileChooserWidget()
self.chooser.set_filename(self.settings['bulkImport-defaultPath'])
+ self.chooser.set_select_multiple(True)
self.vbox.add(self.chooser)
self.chooser.show()
@@ -317,8 +304,20 @@ def main(argv=None):
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",
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)
+ 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()
settings = {}
@@ -350,8 +349,10 @@ def main(argv=None):
importer.setThreads(-1)
importer.addBulkImportImportFileOrDir(os.path.expanduser(options.filename), site=options.filtername)
importer.setCallHud(False)
- importer.runImport()
+ (stored, dups, partial, errs, ttime) = importer.runImport()
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__':
diff --git a/pyfpdb/HUD_config.xml.example b/pyfpdb/HUD_config.xml.example
index de2f1bba..bfeafd8d 100644
--- a/pyfpdb/HUD_config.xml.example
+++ b/pyfpdb/HUD_config.xml.example
@@ -4,8 +4,97 @@
-
+
+
+
diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py
index e71c3ee9..77d8312d 100755
--- a/pyfpdb/HUD_main.py
+++ b/pyfpdb/HUD_main.py
@@ -93,7 +93,7 @@ class HUD_main(object):
self.db_name = db_name
self.config = Configuration.Config(file=options.config, dbname=options.dbname)
self.hud_dict = {}
- self.hud_params = def_hud_params
+ self.hud_params = self.config.get_hud_ui_parameters()
# a thread to read stdin
gobject.threads_init() # this is required
diff --git a/pyfpdb/Hand.py b/pyfpdb/Hand.py
index 2527f636..602a6a1a 100644
--- a/pyfpdb/Hand.py
+++ b/pyfpdb/Hand.py
@@ -205,14 +205,14 @@ db: a connected fpdb_db object"""
#Gametypes
gtid = db.getGameTypeId(self.siteId, self.gametype)
- self.stats.assembleHands(self)
+ self.stats.getStats(self)
#####
# End prep functions
#####
- # HudCache data to come from DerivedStats class
# 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
hh = self.stats.getHands()
@@ -223,6 +223,7 @@ db: a connected fpdb_db object"""
#print hh
handid = db.storeHand(hh)
# HandsPlayers - ? ... Do we fix winnings?
+ db.storeHandsPlayers(handid, sqlids, self.stats.getHandsPlayers())
# Tourneys ?
# TourneysPlayers
diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py
index bb918d97..629f682e 100644
--- a/pyfpdb/SQL.py
+++ b/pyfpdb/SQL.py
@@ -3110,6 +3110,44 @@ class Sql:
self.query['handsPlayersTTypeId_joiner'] = " OR TourneysPlayersId+0="
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':