Merge branch 'master' of git://git.assembla.com/fpdboz
This commit is contained in:
commit
a7bace7ddc
|
@ -32,12 +32,12 @@ import shutil
|
|||
import xml.dom.minidom
|
||||
from xml.dom.minidom import Node
|
||||
|
||||
def fix_tf(x):
|
||||
def fix_tf(x, default = True):
|
||||
if x == "1" or x == 1 or string.lower(x) == "true" or string.lower(x) == "t":
|
||||
return True
|
||||
if x == "0" or x == 0 or string.lower(x) == "false" or string.lower(x) == "f":
|
||||
return False
|
||||
return False
|
||||
return default
|
||||
|
||||
class Layout:
|
||||
def __init__(self, node):
|
||||
|
@ -212,18 +212,12 @@ class Import:
|
|||
self.interval = node.getAttribute("interval")
|
||||
self.callFpdbHud = node.getAttribute("callFpdbHud")
|
||||
self.hhArchiveBase = node.getAttribute("hhArchiveBase")
|
||||
if node.hasAttribute("saveActions"):
|
||||
self.saveActions = fix_tf(node.getAttribute("saveActions"))
|
||||
else:
|
||||
self.saveActions = True
|
||||
if node.hasAttribute("fastStoreHudCache"):
|
||||
self.fastStoreHudCache = fix_tf(node.getAttribute("fastStoreHudCache"))
|
||||
else:
|
||||
self.fastStoreHudCache = False
|
||||
self.saveActions = fix_tf(node.getAttribute("saveActions"), True)
|
||||
self.fastStoreHudCache = fix_tf(node.getAttribute("fastStoreHudCache"), True)
|
||||
|
||||
def __str__(self):
|
||||
return " interval = %s\n callFpdbHud = %s\n hhArchiveBase = %s\n saveActions = %s\n fastStoreHudCache = %s\n" \
|
||||
% (self.interval, self.callFpdbHud, self.hhArchiveBase, self.saveActions, self.saveActions)
|
||||
% (self.interval, self.callFpdbHud, self.hhArchiveBase, self.saveActions, self.fastStoreHudCache)
|
||||
|
||||
class Tv:
|
||||
def __init__(self, node):
|
||||
|
|
|
@ -122,21 +122,10 @@ follow : whether to tail -f the input"""
|
|||
hand.handid = m.group('HID')
|
||||
hand.tablename = m.group('TABLE')
|
||||
hand.starttime = time.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d")
|
||||
|
||||
# attributes
|
||||
# (deep 6)
|
||||
# (6 max)
|
||||
#
|
||||
# be goodd idea to log those what we don't know idea
|
||||
hand.maxseats = 8 # assume 8-max until we see otherwise
|
||||
# stud tables are usually 8-max?
|
||||
#
|
||||
atts = m.group('ATTRIBUTES')
|
||||
if atts:
|
||||
# TODO: parse these
|
||||
pass
|
||||
|
||||
|
||||
if m.group('TABLEATTRIBUTES'):
|
||||
m2 = re.search("(\d+) max", m.group('TABLEATTRIBUTES'))
|
||||
hand.maxseats = int(m2.group(1))
|
||||
# These work, but the info is already in the Hand class - should be used for tourneys though.
|
||||
# m.group('SB')
|
||||
# m.group('BB')
|
||||
|
|
|
@ -176,7 +176,10 @@ class GuiBulkImport():
|
|||
# ComboBox - filter
|
||||
self.cbfilter = gtk.combo_box_new_text()
|
||||
self.cbfilter.append_text("passthrough")
|
||||
self.cbfilter.append_text("Everleaf")
|
||||
self.cbfilter.append_text("BetfairToFpdb")
|
||||
self.cbfilter.append_text("EverleafToFpdb")
|
||||
self.cbfilter.append_text("FulltiltToFpdb")
|
||||
self.cbfilter.append_text("PokerStarsToFpdb")
|
||||
self.cbfilter.set_active(0)
|
||||
self.table.attach(self.cbfilter, 3, 4, 2, 3, xpadding = 10, ypadding = 0, yoptions=gtk.SHRINK)
|
||||
self.cbfilter.show()
|
||||
|
|
|
@ -123,7 +123,7 @@ class HUD_main(object):
|
|||
gtk.gdk.threads_enter()
|
||||
try:
|
||||
self.hud_dict[table_name].update(new_hand_id, config)
|
||||
map(lambda aw: aw.update_gui(new_hand_id), self.hud_dict[table_name].aux_windows)
|
||||
[aw.update_gui(new_hand_id) for aw in self.hud_dict[table_name].aux_windows]
|
||||
return False
|
||||
finally:
|
||||
gtk.gdk.threads_leave()
|
||||
|
@ -151,7 +151,9 @@ class HUD_main(object):
|
|||
try:
|
||||
(table_name, max, poker_game) = self.db_connection.get_table_name(new_hand_id)
|
||||
stat_dict = self.db_connection.get_stats_from_hand(new_hand_id)
|
||||
cards = self.db_connection.get_cards(new_hand_id)
|
||||
cards = self.db_connection.get_cards(new_hand_id)
|
||||
comm_cards = self.db_connection.get_common_cards(new_hand_id)
|
||||
cards['common'] = comm_cards['common']
|
||||
except Exception, err:
|
||||
print "db error: skipping ", new_hand_id, err
|
||||
sys.stderr.write("Database error %s in hand %d. Skipping.\n" % (err, int(new_hand_id)))
|
||||
|
@ -172,8 +174,7 @@ class HUD_main(object):
|
|||
if temp_key in self.hud_dict:
|
||||
self.hud_dict[temp_key].stat_dict = stat_dict
|
||||
self.hud_dict[temp_key].cards = cards
|
||||
for aw in self.hud_dict[temp_key].aux_windows:
|
||||
aw.update_data(new_hand_id, self.db_connection)
|
||||
[aw.update_data(new_hand_id, self.db_connection) for aw in self.hud_dict[temp_key].aux_windows]
|
||||
self.update_HUD(new_hand_id, temp_key, self.config)
|
||||
|
||||
# Or create a new HUD
|
||||
|
|
|
@ -99,3 +99,15 @@ class Hello_plus(Aux_Window):
|
|||
# hands played that was updated in the "update_data()" function.
|
||||
self.label.set_text("Hello %s\nYou have played %d hands\n on %s." % (self.hero, self.hands_played, self.site))
|
||||
|
||||
class Hello_Menu(Aux_Window):
|
||||
"""A 'Hello World' Aux_Window demo."""
|
||||
def create(self):
|
||||
# This demo puts a menu item on the HUD mainwindow.
|
||||
self.item = gtk.MenuItem('Print cards')
|
||||
self.hud.menu.append(self.item)
|
||||
self.item.connect("activate", self.print_cards)
|
||||
self.item.show()
|
||||
|
||||
def print_cards(self, *args):
|
||||
# callback for the menu item
|
||||
print "cards =", self.hud.cards
|
||||
|
|
|
@ -196,7 +196,7 @@ class Hud:
|
|||
s.window.destroy()
|
||||
self.stat_windows = {}
|
||||
# also kill any aux windows
|
||||
map(lambda m: m.destroy(), self.aux_windows)
|
||||
[aux.destroy() for aux in self.aux_windows]
|
||||
self.aux_windows = []
|
||||
|
||||
def reposition_windows(self, *args):
|
||||
|
@ -217,8 +217,7 @@ class Hud:
|
|||
new_layout[self.stat_windows[sw].adj - 1] = new_loc
|
||||
self.config.edit_layout(self.table.site, self.max, locations = new_layout)
|
||||
# ask each aux to save its layout back to the config object
|
||||
for aux in self.aux_windows:
|
||||
aux.save_layout()
|
||||
[aux.save_layout() for aux in self.aux_windows]
|
||||
# save the config object back to the file
|
||||
print "saving new xml file"
|
||||
self.config.save()
|
||||
|
@ -351,6 +350,8 @@ class Hud:
|
|||
style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE)
|
||||
style |= win32con.WS_CLIPCHILDREN
|
||||
win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style)
|
||||
break
|
||||
|
||||
window.set_title(real_name)
|
||||
|
||||
class Stat_Window:
|
||||
|
@ -575,6 +576,7 @@ class Popup_window:
|
|||
style = win32gui.GetWindowLong(self.table.number, win32con.GWL_EXSTYLE)
|
||||
style |= win32con.WS_CLIPCHILDREN
|
||||
win32gui.SetWindowLong(self.table.number, win32con.GWL_EXSTYLE, style)
|
||||
break
|
||||
|
||||
window.set_title(real_name)
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ Mucked cards display for FreePokerTools HUD.
|
|||
|
||||
# Standard Library modules
|
||||
import sys
|
||||
import pprint
|
||||
|
||||
# pyGTK modules
|
||||
import pygtk
|
||||
|
@ -37,7 +38,7 @@ import Database
|
|||
|
||||
class Aux_Window:
|
||||
def __init__(self, hud, params, config):
|
||||
self.config = hud
|
||||
self.hud = hud
|
||||
self.config = config
|
||||
|
||||
def update_data(self, *parms):
|
||||
|
@ -318,6 +319,7 @@ class Flop_Mucked(Aux_Window):
|
|||
self.params = params # dict aux params from config
|
||||
self.positions = {} # dict of window positions
|
||||
self.displayed_cards = False
|
||||
self.timer_on = False # bool = Ture if the timeout for removing the cards is on
|
||||
self.card_images = self.get_card_images()
|
||||
|
||||
def create(self):
|
||||
|
@ -349,10 +351,6 @@ class Flop_Mucked(Aux_Window):
|
|||
self.m_windows[i].show_all()
|
||||
self.m_windows[i].hide()
|
||||
|
||||
def update_data(self, new_hand_id, db_connection):
|
||||
cards = db_connection.get_common_cards(new_hand_id)
|
||||
self.hud.cards['common'] = cards['common']
|
||||
|
||||
def update_gui(self, new_hand_id):
|
||||
"""Prepare and show the mucked cards."""
|
||||
if self.displayed_cards:
|
||||
|
@ -378,35 +376,64 @@ class Flop_Mucked(Aux_Window):
|
|||
self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back
|
||||
self.displayed_cards = True
|
||||
|
||||
for stats in self.hud.stat_dict.itervalues():
|
||||
self.eb[stats['seat']].set_tooltip_text(stats['screen_name'])
|
||||
|
||||
if self.displayed_cards and float(self.params['timeout']) > 0:
|
||||
gobject.timeout_add(int(1000*float(self.params['timeout'])), self.hide_mucked_cards)
|
||||
self.timer_on = True
|
||||
gobject.timeout_add(int(1000*float(self.params['timeout'])), self.timed_out)
|
||||
|
||||
def destroy(self):
|
||||
"""Destroy all of the mucked windows."""
|
||||
for w in self.m_windows.values():
|
||||
w.destroy()
|
||||
|
||||
def timed_out(self):
|
||||
# this is the callback from the timeout
|
||||
|
||||
# if timer_on is False the user has cancelled the timer with a click
|
||||
# so just return False to cancel the timer
|
||||
if not self.timer_on:
|
||||
return False
|
||||
else:
|
||||
self.hide_mucked_cards()
|
||||
return False
|
||||
|
||||
def hide_mucked_cards(self):
|
||||
"""Hide the mucked card windows."""
|
||||
# this is the callback from the timeout
|
||||
for (i, w) in self.m_windows.iteritems():
|
||||
self.positions[i] = w.get_position()
|
||||
w.hide()
|
||||
self.displayed_cards = False
|
||||
return False # this tells the system to NOT run this timeout again
|
||||
|
||||
def button_press_cb(self, widget, event, *args):
|
||||
"""Handle button clicks in the event boxes."""
|
||||
|
||||
# shift-any button exposes all the windows and turns off the timer
|
||||
if event.state & gtk.gdk.SHIFT_MASK:
|
||||
self.timer_on = False
|
||||
self.expose_all()
|
||||
|
||||
if event.button == 3: # right button event
|
||||
pass
|
||||
|
||||
elif event.button == 2: # middle button event
|
||||
self.hide_mucked_cards()
|
||||
if self.timer_on == True:
|
||||
self.timer_on = False
|
||||
else:
|
||||
self.timer_on = False
|
||||
self.hide_mucked_cards()
|
||||
|
||||
elif event.button == 1: # left button event
|
||||
window = widget.get_parent()
|
||||
window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time)
|
||||
|
||||
def expose_all(self):
|
||||
for (i, cards) in self.hud.cards.iteritems():
|
||||
self.m_windows[i].present()
|
||||
self.m_windows[i].move(self.positions[i][0], self.positions[i][1]) # here is where I move back
|
||||
self.displayed_cards = True
|
||||
|
||||
def save_layout(self, *args):
|
||||
"""Save new layout back to the aux element in the config file."""
|
||||
new_locs = {}
|
||||
|
|
|
@ -81,23 +81,13 @@ class fpdb:
|
|||
def display_tab(self, new_tab_name):
|
||||
"""displays the indicated tab"""
|
||||
#print "start of display_tab, len(self.tab_names):",len(self.tab_names)
|
||||
tab_no=-1
|
||||
#if len(self.tab_names)>1:
|
||||
for i in range(len(self.tab_names)):
|
||||
#print "display_tab, new_tab_name:",new_tab_name," self.tab_names[i]:", self.tab_names[i]
|
||||
if (new_tab_name==self.tab_names[i]):
|
||||
tab_no=i
|
||||
#self.tab_buttons[i].set_active(False)
|
||||
#else:
|
||||
# tab_no=0
|
||||
tab_no = -1
|
||||
for i, name in enumerate(self.tab_names):
|
||||
if name == new_tab_name:
|
||||
tab_no = i
|
||||
break
|
||||
|
||||
#current_tab_no=-1
|
||||
for i in range(len(self.tab_names)):
|
||||
if self.current_tab==self.tabs[i]:
|
||||
#self.tab_buttons[i].set_active(False)
|
||||
pass
|
||||
|
||||
if tab_no==-1:
|
||||
if tab_no == -1:
|
||||
raise fpdb_simple.FpdbError("invalid tab_no")
|
||||
else:
|
||||
self.main_vbox.remove(self.current_tab)
|
||||
|
@ -199,12 +189,13 @@ class fpdb:
|
|||
def dia_recreate_tables(self, widget, data):
|
||||
"""Dialogue that asks user to confirm that he wants to delete and recreate the tables"""
|
||||
self.obtain_global_lock()
|
||||
dia_confirm=gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING,
|
||||
|
||||
dia_confirm = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_WARNING,
|
||||
buttons=(gtk.BUTTONS_YES_NO), message_format="Confirm deleting and recreating tables")
|
||||
diastring=("Please confirm that you want to (re-)create the tables. If there already are tables in the database "+self.db.database+" on "+self.db.host+" they will be deleted.")
|
||||
diastring = "Please confirm that you want to (re-)create the tables. If there already are tables in the database "+self.db.database+" on "+self.db.host+" they will be deleted."
|
||||
dia_confirm.format_secondary_text(diastring)#todo: make above string with bold for db, host and deleted
|
||||
|
||||
response=dia_confirm.run()
|
||||
response = dia_confirm.run()
|
||||
dia_confirm.destroy()
|
||||
if response == gtk.RESPONSE_YES:
|
||||
self.db.recreate_tables()
|
||||
|
|
|
@ -23,12 +23,12 @@ import FpdbSQLQueries
|
|||
class fpdb_db:
|
||||
def __init__(self):
|
||||
"""Simple constructor, doesnt really do anything"""
|
||||
self.db=None
|
||||
self.cursor=None
|
||||
self.sql = {}
|
||||
self.MYSQL_INNODB=2
|
||||
self.PGSQL=3
|
||||
self.SQLITE=4
|
||||
self.db = None
|
||||
self.cursor = None
|
||||
self.sql = {}
|
||||
self.MYSQL_INNODB = 2
|
||||
self.PGSQL = 3
|
||||
self.SQLITE = 4
|
||||
#end def __init__
|
||||
|
||||
def do_connect(self, config=None):
|
||||
|
@ -37,10 +37,7 @@ class fpdb_db:
|
|||
raise FpdbError('Configuration not defined')
|
||||
|
||||
self.settings = {}
|
||||
if (os.sep=="/"):
|
||||
self.settings['os']="linuxmac"
|
||||
else:
|
||||
self.settings['os']="windows"
|
||||
self.settings['os'] = "linuxmac" if os.name != "nt" else "windows"
|
||||
|
||||
self.settings.update(config.get_db_parameters())
|
||||
self.connect(self.settings['db-backend'],
|
||||
|
|
|
@ -51,22 +51,22 @@ class Importer:
|
|||
|
||||
def __init__(self, caller, settings, config):
|
||||
"""Constructor"""
|
||||
self.settings=settings
|
||||
self.caller=caller
|
||||
self.config = config
|
||||
self.fdb = None
|
||||
self.cursor = None
|
||||
self.filelist = {}
|
||||
self.dirlist = {}
|
||||
self.settings = settings
|
||||
self.caller = caller
|
||||
self.config = config
|
||||
self.fdb = None
|
||||
self.cursor = None
|
||||
self.filelist = {}
|
||||
self.dirlist = {}
|
||||
self.addToDirList = {}
|
||||
self.removeFromFileList = {} # to remove deleted files
|
||||
self.monitor = False
|
||||
self.updated = {} #Time last import was run {file:mtime}
|
||||
self.lines = None
|
||||
self.faobs = None #File as one big string
|
||||
self.monitor = False
|
||||
self.updated = {} #Time last import was run {file:mtime}
|
||||
self.lines = None
|
||||
self.faobs = None #File as one big string
|
||||
self.pos_in_file = {} # dict to remember how far we have read in the file
|
||||
#Set defaults
|
||||
self.callHud = self.config.get_import_parameters().get("callFpdbHud")
|
||||
self.callHud = self.config.get_import_parameters().get("callFpdbHud")
|
||||
if 'minPrint' not in self.settings:
|
||||
#TODO: Is this value in the xml file?
|
||||
self.settings['minPrint'] = 30
|
||||
|
@ -196,24 +196,26 @@ class Importer:
|
|||
self.addImportDirectory(self.dirlist[site][0], False, site, self.dirlist[site][1])
|
||||
|
||||
for file in self.filelist:
|
||||
stat_info = os.stat(file)
|
||||
try:
|
||||
lastupdate = self.updated[file]
|
||||
if stat_info.st_mtime > lastupdate:
|
||||
self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
||||
if os.path.exists(file):
|
||||
stat_info = os.stat(file)
|
||||
try:
|
||||
lastupdate = self.updated[file]
|
||||
if stat_info.st_mtime > lastupdate:
|
||||
self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
||||
self.updated[file] = time()
|
||||
except:
|
||||
self.updated[file] = time()
|
||||
except:
|
||||
self.updated[file] = time()
|
||||
# If modified in the last minute run an immediate import.
|
||||
# This codepath only runs first time the file is found.
|
||||
if os.path.isdir(file) or (time() - stat_info.st_mtime) < 60:
|
||||
# TODO attach a HHC thread to the file
|
||||
# TODO import the output of the HHC thread -- this needs to wait for the HHC to block?
|
||||
self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
||||
# If modified in the last minute run an immediate import.
|
||||
# This codepath only runs first time the file is found.
|
||||
if os.path.isdir(file) or (time() - stat_info.st_mtime) < 60:
|
||||
# TODO attach a HHC thread to the file
|
||||
# TODO import the output of the HHC thread -- this needs to wait for the HHC to block?
|
||||
self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
||||
# TODO we also test if directory, why?
|
||||
#if os.path.isdir(file):
|
||||
#self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1])
|
||||
|
||||
else:
|
||||
removeFromFileList[file] = True
|
||||
self.addToDirList = filter(lambda x: self.addImportDirectory(x, True, self.addToDirList[x][0], self.addToDirList[x][1]), self.addToDirList)
|
||||
|
||||
for file in self.removeFromFileList:
|
||||
|
@ -259,7 +261,6 @@ class Importer:
|
|||
print "Unknown filter filter_name:'%s' in filter:'%s'" %(filter_name, filter)
|
||||
return
|
||||
|
||||
|
||||
#This will barf if conv.getStatus != True
|
||||
return (stored, duplicates, partial, errors, ttime)
|
||||
|
||||
|
|
|
@ -22,47 +22,46 @@ import fpdb_save_to_db
|
|||
|
||||
#parses a holdem hand
|
||||
def mainParser(backend, db, cursor, site, category, hand, config):
|
||||
category=fpdb_simple.recogniseCategory(hand[0])
|
||||
if (category=="holdem" or category=="omahahi" or category=="omahahilo"):
|
||||
base="hold"
|
||||
else:
|
||||
base="stud"
|
||||
category = fpdb_simple.recogniseCategory(hand[0])
|
||||
|
||||
base = "hold" if category == "holdem" or category == "omahahi" or category == "omahahilo" else "stud"
|
||||
|
||||
#part 0: create the empty arrays
|
||||
lineTypes=[] #char, valid values: header, name, cards, action, win, rake, ignore
|
||||
lineStreets=[] #char, valid values: (predeal, preflop, flop, turn, river)
|
||||
lineTypes = [] #char, valid values: header, name, cards, action, win, rake, ignore
|
||||
lineStreets = [] #char, valid values: (predeal, preflop, flop, turn, river)
|
||||
|
||||
cardValues, cardSuits, boardValues, boardSuits, antes, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo, seatLines, winnings, rakes=[],[],[],[],[],[],[],[],[],[],[],[],[]
|
||||
|
||||
#part 1: read hand no and check for duplicate
|
||||
siteHandNo=fpdb_simple.parseSiteHandNo(hand[0])
|
||||
handStartTime=fpdb_simple.parseHandStartTime(hand[0], site)
|
||||
siteID=fpdb_simple.recogniseSiteID(cursor, site)
|
||||
siteHandNo = fpdb_simple.parseSiteHandNo(hand[0])
|
||||
handStartTime = fpdb_simple.parseHandStartTime(hand[0], site)
|
||||
siteID = fpdb_simple.recogniseSiteID(cursor, site)
|
||||
#print "parse logic, siteID:",siteID,"site:",site
|
||||
|
||||
isTourney=fpdb_simple.isTourney(hand[0])
|
||||
smallBlindLine=0
|
||||
for i in range(len(hand)):
|
||||
if 'posts small blind' in hand[i] or 'posts the small blind' in hand[i]:
|
||||
if hand[i][-2:] == "$0":
|
||||
continue
|
||||
smallBlindLine=i
|
||||
#print "found small blind line:",smallBlindLine
|
||||
isTourney = fpdb_simple.isTourney(hand[0])
|
||||
smallBlindLine = 0
|
||||
for i, line in enumerate(hand):
|
||||
if 'posts small blind' in line or 'posts the small blind' in line:
|
||||
if line[-2:] == "$0": continue
|
||||
smallBlindLine = i
|
||||
break
|
||||
#print "small blind line:",smallBlindLine
|
||||
gametypeID=fpdb_simple.recogniseGametypeID(backend, db, cursor, hand[0], hand[smallBlindLine], siteID, category, isTourney)
|
||||
|
||||
gametypeID = fpdb_simple.recogniseGametypeID(backend, db, cursor, hand[0], hand[smallBlindLine], siteID, category, isTourney)
|
||||
if isTourney:
|
||||
if site!="ps":
|
||||
if site != "ps":
|
||||
raise fpdb_simple.FpdbError("tourneys are only supported on PS right now")
|
||||
siteTourneyNo=fpdb_simple.parseTourneyNo(hand[0])
|
||||
buyin=fpdb_simple.parseBuyin(hand[0])
|
||||
fee=fpdb_simple.parseFee(hand[0])
|
||||
entries=-1 #todo: parse this
|
||||
prizepool=-1 #todo: parse this
|
||||
knockout=0
|
||||
tourneyStartTime=handStartTime #todo: read tourney start time
|
||||
rebuyOrAddon=fpdb_simple.isRebuyOrAddon(hand[0])
|
||||
siteTourneyNo = fpdb_simple.parseTourneyNo(hand[0])
|
||||
buyin = fpdb_simple.parseBuyin(hand[0])
|
||||
fee = fpdb_simple.parseFee(hand[0])
|
||||
entries = -1 #todo: parse this
|
||||
prizepool = -1 #todo: parse this
|
||||
knockout = 0
|
||||
tourneyStartTime= handStartTime #todo: read tourney start time
|
||||
rebuyOrAddon = fpdb_simple.isRebuyOrAddon(hand[0])
|
||||
|
||||
tourneyTypeId=fpdb_simple.recogniseTourneyTypeId(cursor, siteID, buyin, fee, knockout, rebuyOrAddon)
|
||||
tourneyTypeId = fpdb_simple.recogniseTourneyTypeId(cursor, siteID, buyin, fee, knockout, rebuyOrAddon)
|
||||
|
||||
fpdb_simple.isAlreadyInDB(cursor, gametypeID, siteHandNo)
|
||||
|
||||
hand=fpdb_simple.filterCrap(site, hand, isTourney)
|
||||
|
@ -72,85 +71,82 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
|||
|
||||
#part 3: read basic player info
|
||||
#3a read player names, startcashes
|
||||
for i in range (len(hand)): #todo: use maxseats+1 here.
|
||||
if (lineTypes[i]=="name"):
|
||||
seatLines.append(hand[i])
|
||||
names=fpdb_simple.parseNames(seatLines)
|
||||
playerIDs = fpdb_simple.recognisePlayerIDs(cursor, names, siteID)
|
||||
tmp=fpdb_simple.parseCashesAndSeatNos(seatLines, site)
|
||||
startCashes=tmp['startCashes']
|
||||
seatNos=tmp['seatNos']
|
||||
for i, line in enumerate(hand):
|
||||
if lineTypes[i] == "name":
|
||||
seatLines.append(line)
|
||||
|
||||
names = fpdb_simple.parseNames(seatLines)
|
||||
playerIDs = fpdb_simple.recognisePlayerIDs(cursor, names, siteID)
|
||||
tmp = fpdb_simple.parseCashesAndSeatNos(seatLines, site)
|
||||
startCashes = tmp['startCashes']
|
||||
seatNos = tmp['seatNos']
|
||||
|
||||
fpdb_simple.createArrays(category, len(names), cardValues, cardSuits, antes, winnings, rakes, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
||||
|
||||
#3b read positions
|
||||
if base=="hold":
|
||||
positions = fpdb_simple.parsePositions (hand, names)
|
||||
if base == "hold":
|
||||
positions = fpdb_simple.parsePositions(hand, names)
|
||||
|
||||
#part 4: take appropriate action for each line based on linetype
|
||||
for i in range(len(hand)):
|
||||
if (lineTypes[i]=="cards"):
|
||||
fpdb_simple.parseCardLine (site, category, lineStreets[i], hand[i], names, cardValues, cardSuits, boardValues, boardSuits)
|
||||
for i, line in enumerate(hand):
|
||||
if lineTypes[i] == "cards":
|
||||
fpdb_simple.parseCardLine(site, category, lineStreets[i], line, names, cardValues, cardSuits, boardValues, boardSuits)
|
||||
#if category=="studhilo":
|
||||
# print "hand[i]:", hand[i]
|
||||
# print "cardValues:", cardValues
|
||||
# print "cardSuits:", cardSuits
|
||||
elif (lineTypes[i]=="action"):
|
||||
fpdb_simple.parseActionLine (site, base, isTourney, hand[i], lineStreets[i], playerIDs, names, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
||||
elif (lineTypes[i]=="win"):
|
||||
fpdb_simple.parseWinLine (hand[i], site, names, winnings, isTourney)
|
||||
elif (lineTypes[i]=="rake"):
|
||||
if isTourney:
|
||||
totalRake=0
|
||||
else:
|
||||
totalRake=fpdb_simple.parseRake(hand[i])
|
||||
elif lineTypes[i] == "action":
|
||||
fpdb_simple.parseActionLine(site, base, isTourney, line, lineStreets[i], playerIDs, names, actionTypes, allIns, actionAmounts, actionNos, actionTypeByNo)
|
||||
elif lineTypes[i] == "win":
|
||||
fpdb_simple.parseWinLine(line, site, names, winnings, isTourney)
|
||||
elif lineTypes[i] == "rake":
|
||||
totalRake = 0 if isTourney else fpdb_simple.parseRake(line)
|
||||
fpdb_simple.splitRake(winnings, rakes, totalRake)
|
||||
elif (lineTypes[i]=="header" or lineTypes[i]=="rake" or lineTypes[i]=="name" or lineTypes[i]=="ignore"):
|
||||
elif lineTypes[i]=="header" or lineTypes[i]=="rake" or lineTypes[i]=="name" or lineTypes[i]=="ignore":
|
||||
pass
|
||||
elif (lineTypes[i]=="ante"):
|
||||
fpdb_simple.parseAnteLine(hand[i], site, isTourney, names, antes)
|
||||
elif (lineTypes[i]=="table"):
|
||||
tableResult=fpdb_simple.parseTableLine(site, base, hand[i])
|
||||
elif lineTypes[i]=="ante":
|
||||
fpdb_simple.parseAnteLine(line, site, isTourney, names, antes)
|
||||
elif lineTypes[i]=="table":
|
||||
tableResult=fpdb_simple.parseTableLine(site, base, line)
|
||||
else:
|
||||
raise fpdb_simple.FpdbError("unrecognised lineType:"+lineTypes[i])
|
||||
if site=="ftp":
|
||||
tableResult=fpdb_simple.parseTableLine(site, base, hand[0])
|
||||
maxSeats=tableResult['maxSeats']
|
||||
tableName=tableResult['tableName']
|
||||
|
||||
if site == "ftp":
|
||||
tableResult = fpdb_simple.parseTableLine(site, base, hand[0])
|
||||
|
||||
maxSeats = tableResult['maxSeats']
|
||||
tableName = tableResult['tableName']
|
||||
#print "before part5, antes:", antes
|
||||
|
||||
#part 5: final preparations, then call fpdb_save_to_db.* with
|
||||
# the arrays as they are - that file will fill them.
|
||||
fpdb_simple.convertCardValues(cardValues)
|
||||
if base=="hold":
|
||||
if base == "hold":
|
||||
fpdb_simple.convertCardValuesBoard(boardValues)
|
||||
fpdb_simple.convertBlindBet(actionTypes, actionAmounts)
|
||||
fpdb_simple.checkPositions(positions)
|
||||
|
||||
cursor.execute("SELECT limitType FROM Gametypes WHERE id=%s",(gametypeID, ))
|
||||
limit_type=cursor.fetchone()[0]
|
||||
limit_type = cursor.fetchone()[0]
|
||||
fpdb_simple.convert3B4B(site, category, limit_type, actionTypes, actionAmounts)
|
||||
|
||||
totalWinnings=0
|
||||
for i in range(len(winnings)):
|
||||
totalWinnings+=winnings[i]
|
||||
totalWinnings = sum(winnings)
|
||||
|
||||
if base=="hold":
|
||||
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
||||
# if hold'em, use positions and not antes, if stud do not use positions, use antes
|
||||
if base == "hold":
|
||||
hudImportData = fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
||||
, allIns, actionTypeByNo, winnings, totalWinnings, positions
|
||||
, actionTypes, actionAmounts, None)
|
||||
else:
|
||||
hudImportData=fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
||||
hudImportData = fpdb_simple.generateHudCacheData(playerIDs, base, category, actionTypes
|
||||
, allIns, actionTypeByNo, winnings, totalWinnings, None
|
||||
, actionTypes, actionAmounts, antes)
|
||||
|
||||
if isTourney:
|
||||
ranks=[]
|
||||
for i in range (len(names)):
|
||||
ranks.append(0)
|
||||
payin_amounts=fpdb_simple.calcPayin(len(names), buyin, fee)
|
||||
ranks = map(lambda x: 0, names) # create an array of 0's equal to the length of names
|
||||
payin_amounts = fpdb_simple.calcPayin(len(names), buyin, fee)
|
||||
|
||||
if base=="hold":
|
||||
if base == "hold":
|
||||
result = fpdb_save_to_db.tourney_holdem_omaha(
|
||||
config, backend, db, cursor, base, category, siteTourneyNo, buyin
|
||||
, fee, knockout, entries, prizepool, tourneyStartTime
|
||||
|
@ -159,7 +155,7 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
|||
, positions, cardValues, cardSuits, boardValues, boardSuits
|
||||
, winnings, rakes, actionTypes, allIns, actionAmounts
|
||||
, actionNos, hudImportData, maxSeats, tableName, seatNos)
|
||||
elif base=="stud":
|
||||
elif base == "stud":
|
||||
result = fpdb_save_to_db.tourney_stud(
|
||||
config, backend, db, cursor, base, category, siteTourneyNo
|
||||
, buyin, fee, knockout, entries, prizepool, tourneyStartTime
|
||||
|
@ -169,9 +165,9 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
|||
, allIns, actionAmounts, actionNos, hudImportData, maxSeats
|
||||
, tableName, seatNos)
|
||||
else:
|
||||
raise fpdb_simple.FpdbError ("unrecognised category")
|
||||
raise fpdb_simple.FpdbError("unrecognised category") # it's impossible to get here, but w/e
|
||||
else:
|
||||
if base=="hold":
|
||||
if base == "hold":
|
||||
result = fpdb_save_to_db.ring_holdem_omaha(
|
||||
config, backend, db, cursor, base, category, siteHandNo
|
||||
, gametypeID, handStartTime, names, playerIDs
|
||||
|
@ -179,7 +175,7 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
|||
, boardValues, boardSuits, winnings, rakes
|
||||
, actionTypes, allIns, actionAmounts, actionNos
|
||||
, hudImportData, maxSeats, tableName, seatNos)
|
||||
elif base=="stud":
|
||||
elif base == "stud":
|
||||
result = fpdb_save_to_db.ring_stud(
|
||||
config, backend, db, cursor, base, category, siteHandNo, gametypeID
|
||||
, handStartTime, names, playerIDs, startCashes, antes
|
||||
|
@ -187,7 +183,7 @@ def mainParser(backend, db, cursor, site, category, hand, config):
|
|||
, actionAmounts, actionNos, hudImportData, maxSeats, tableName
|
||||
, seatNos)
|
||||
else:
|
||||
raise fpdb_simple.FpdbError ("unrecognised category")
|
||||
raise fpdb_simple.FpdbError ("unrecognised category") # also impossible to get here
|
||||
db.commit()
|
||||
return result
|
||||
#end def mainParser
|
||||
|
|
|
@ -22,13 +22,13 @@ from time import time
|
|||
|
||||
import fpdb_simple
|
||||
|
||||
MYSQL_INNODB=2
|
||||
PGSQL=3
|
||||
SQLITE=4
|
||||
MYSQL_INNODB = 2
|
||||
PGSQL = 3
|
||||
SQLITE = 4
|
||||
|
||||
fastStoreHudCache=True # set this to True to test the new storeHudCache routine
|
||||
fastStoreHudCache = True # set this to True to test the new storeHudCache routine
|
||||
|
||||
saveActions=False # set this to False to avoid storing action data
|
||||
saveActions = False # set this to False to avoid storing action data
|
||||
# Pros: speeds up imports
|
||||
# Cons: no action data is saved, so you need to keep the hand histories
|
||||
# variance not available on stats page
|
||||
|
@ -41,16 +41,17 @@ def ring_stud(config, backend, db, cursor, base, category, site_hand_no, gametyp
|
|||
,seatNos):
|
||||
|
||||
import_options = config.get_import_parameters()
|
||||
saveActions = import_options['saveActions']
|
||||
fastStoreHudCache = import_options['fastStoreHudCache']
|
||||
|
||||
saveActions = True if import_options['saveActions'] == 'True' else False
|
||||
fastStoreHudCache = True if import_options['fastStoreHudCache'] == 'True' else False
|
||||
|
||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||
|
||||
hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
||||
hands_id = fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
||||
,hand_start_time, names, tableName, maxSeats)
|
||||
|
||||
#print "before calling store_hands_players_stud, antes:", antes
|
||||
hands_players_ids=fpdb_simple.store_hands_players_stud(backend, db, cursor, hands_id, player_ids
|
||||
hands_players_ids = fpdb_simple.store_hands_players_stud(backend, db, cursor, hands_id, player_ids
|
||||
,start_cashes, antes, card_values
|
||||
,card_suits, winnings, rakes, seatNos)
|
||||
|
||||
|
@ -69,8 +70,8 @@ def ring_holdem_omaha(config, backend, db, cursor, base, category, site_hand_no,
|
|||
"""stores a holdem/omaha hand into the database"""
|
||||
|
||||
import_options = config.get_import_parameters()
|
||||
saveActions = import_options['saveActions']
|
||||
fastStoreHudCache = import_options['fastStoreHudCache']
|
||||
saveActions = True if import_options['saveActions'] == 'True' else False
|
||||
fastStoreHudCache = True if import_options['fastStoreHudCache'] == 'True' else False
|
||||
|
||||
t0 = time()
|
||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||
|
@ -78,10 +79,10 @@ def ring_holdem_omaha(config, backend, db, cursor, base, category, site_hand_no,
|
|||
fpdb_simple.fill_board_cards(board_values, board_suits)
|
||||
t2 = time()
|
||||
|
||||
hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
||||
hands_id = fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
||||
,hand_start_time, names, tableName, maxSeats)
|
||||
t3 = time()
|
||||
hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha(
|
||||
hands_players_ids = fpdb_simple.store_hands_players_holdem_omaha(
|
||||
backend, db, cursor, category, hands_id, player_ids, start_cashes
|
||||
, positions, card_values, card_suits, winnings, rakes, seatNos)
|
||||
t4 = time()
|
||||
|
@ -110,19 +111,19 @@ def tourney_holdem_omaha(config, backend, db, cursor, base, category, siteTourne
|
|||
"""stores a tourney holdem/omaha hand into the database"""
|
||||
|
||||
import_options = config.get_import_parameters()
|
||||
saveActions = import_options['saveActions']
|
||||
fastStoreHudCache = import_options['fastStoreHudCache']
|
||||
saveActions = True if import_options['saveActions'] == 'True' else False
|
||||
fastStoreHudCache = True if import_options['fastStoreHudCache'] == 'True' else False
|
||||
|
||||
fpdb_simple.fillCardArrays(len(names), base, category, card_values, card_suits)
|
||||
fpdb_simple.fill_board_cards(board_values, board_suits)
|
||||
|
||||
tourney_id=fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourney_start)
|
||||
tourneys_players_ids=fpdb_simple.store_tourneys_players(cursor, tourney_id, player_ids, payin_amounts, ranks, winnings)
|
||||
tourney_id = fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourney_start)
|
||||
tourneys_players_ids = fpdb_simple.store_tourneys_players(cursor, tourney_id, player_ids, payin_amounts, ranks, winnings)
|
||||
|
||||
hands_id=fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
||||
hands_id = fpdb_simple.storeHands(backend, db, cursor, site_hand_no, gametype_id
|
||||
,hand_start_time, names, tableName, maxSeats)
|
||||
|
||||
hands_players_ids=fpdb_simple.store_hands_players_holdem_omaha_tourney(
|
||||
hands_players_ids = fpdb_simple.store_hands_players_holdem_omaha_tourney(
|
||||
backend, db, cursor, category, hands_id, player_ids, start_cashes, positions
|
||||
, card_values, card_suits, winnings, rakes, seatNos, tourneys_players_ids)
|
||||
|
||||
|
@ -147,18 +148,18 @@ def tourney_stud(config, backend, db, cursor, base, category, siteTourneyNo, buy
|
|||
#stores a tourney stud/razz hand into the database
|
||||
|
||||
import_options = config.get_import_parameters()
|
||||
saveActions = import_options['saveActions']
|
||||
fastStoreHudCache = import_options['fastStoreHudCache']
|
||||
saveActions = True if import_options['saveActions'] == 'True' else False
|
||||
fastStoreHudCache = True if import_options['fastStoreHudCache'] == 'True' else False
|
||||
|
||||
fpdb_simple.fillCardArrays(len(names), base, category, cardValues, cardSuits)
|
||||
|
||||
tourney_id=fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourneyStartTime)
|
||||
tourney_id = fpdb_simple.store_tourneys(cursor, tourneyTypeId, siteTourneyNo, entries, prizepool, tourneyStartTime)
|
||||
|
||||
tourneys_players_ids=fpdb_simple.store_tourneys_players(cursor, tourney_id, playerIds, payin_amounts, ranks, winnings)
|
||||
tourneys_players_ids = fpdb_simple.store_tourneys_players(cursor, tourney_id, playerIds, payin_amounts, ranks, winnings)
|
||||
|
||||
hands_id=fpdb_simple.storeHands(backend, db, cursor, siteHandNo, gametypeId, handStartTime, names, tableName, maxSeats)
|
||||
hands_id = fpdb_simple.storeHands(backend, db, cursor, siteHandNo, gametypeId, handStartTime, names, tableName, maxSeats)
|
||||
|
||||
hands_players_ids=fpdb_simple.store_hands_players_stud_tourney(backend, db, cursor, hands_id
|
||||
hands_players_ids = fpdb_simple.store_hands_players_stud_tourney(backend, db, cursor, hands_id
|
||||
, playerIds, startCashes, antes, cardValues, cardSuits
|
||||
, winnings, rakes, seatNos, tourneys_players_ids)
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user