Merge branch 'master' of git://git.assembla.com/fpdboz
This commit is contained in:
commit
48930e1679
|
@ -51,7 +51,7 @@ if __name__ == "__main__":
|
|||
parser.add_option("-x", "--failOnError", action="store_true",
|
||||
help="If this option is passed it quits when it encounters any error")
|
||||
|
||||
(options, sys.argv) = parser.parse_args()
|
||||
(options, argv) = parser.parse_args()
|
||||
|
||||
settings={'callFpdbHud':False, 'db-backend':2}
|
||||
settings['db-host']=options.server
|
||||
|
|
|
@ -55,15 +55,18 @@ def get_exec_path():
|
|||
if hasattr(sys, "frozen"): # compiled by py2exe
|
||||
return os.path.dirname(sys.executable)
|
||||
else:
|
||||
return os.path.dirname(sys.path[0])
|
||||
pathname = os.path.dirname(sys.argv[0])
|
||||
return os.path.abspath(pathname)
|
||||
|
||||
def get_config(file_name, fallback = True):
|
||||
"""Looks in cwd and in self.default_config_path for a config file."""
|
||||
config_path = os.path.join(get_exec_path(), file_name)
|
||||
# print "config_path=", config_path
|
||||
if os.path.exists(config_path): # there is a file in the cwd
|
||||
return config_path # so we use it
|
||||
else: # no file in the cwd, look where it should be in the first place
|
||||
config_path = os.path.join(get_default_config_path(), file_name)
|
||||
# print "config path 2=", config_path
|
||||
if os.path.exists(config_path):
|
||||
return config_path
|
||||
|
||||
|
|
|
@ -1343,7 +1343,9 @@ class Database:
|
|||
|
||||
q = q.replace('%s', self.sql.query['placeholder'])
|
||||
|
||||
self.cursor.execute(q, (
|
||||
c = self.connection.cursor()
|
||||
|
||||
c.execute(q, (
|
||||
p['tableName'],
|
||||
p['gameTypeId'],
|
||||
p['siteHandNo'],
|
||||
|
@ -1374,7 +1376,7 @@ class Database:
|
|||
p['street4Pot'],
|
||||
p['showdownPot']
|
||||
))
|
||||
return self.get_last_insert_id(self.cursor)
|
||||
return self.get_last_insert_id(c)
|
||||
# def storeHand
|
||||
|
||||
def storeHandsPlayers(self, hid, pids, pdata):
|
||||
|
@ -1385,17 +1387,39 @@ class Database:
|
|||
pids[p],
|
||||
pdata[p]['startCash'],
|
||||
pdata[p]['seatNo'],
|
||||
pdata[p]['card1'],
|
||||
pdata[p]['card2'],
|
||||
pdata[p]['card3'],
|
||||
pdata[p]['card4'],
|
||||
pdata[p]['card5'],
|
||||
pdata[p]['card6'],
|
||||
pdata[p]['card7'],
|
||||
pdata[p]['winnings'],
|
||||
pdata[p]['rake'],
|
||||
pdata[p]['totalProfit'],
|
||||
pdata[p]['street0VPI'],
|
||||
pdata[p]['street1Seen'],
|
||||
pdata[p]['street2Seen'],
|
||||
pdata[p]['street3Seen'],
|
||||
pdata[p]['street4Seen'],
|
||||
pdata[p]['sawShowdown'],
|
||||
pdata[p]['wonAtSD'],
|
||||
pdata[p]['street0Aggr'],
|
||||
pdata[p]['street1Aggr'],
|
||||
pdata[p]['street2Aggr'],
|
||||
pdata[p]['street3Aggr'],
|
||||
pdata[p]['street4Aggr']
|
||||
pdata[p]['street4Aggr'],
|
||||
pdata[p]['wonWhenSeenStreet1'],
|
||||
pdata[p]['street0Calls'],
|
||||
pdata[p]['street1Calls'],
|
||||
pdata[p]['street2Calls'],
|
||||
pdata[p]['street3Calls'],
|
||||
pdata[p]['street4Calls'],
|
||||
pdata[p]['street0Bets'],
|
||||
pdata[p]['street1Bets'],
|
||||
pdata[p]['street2Bets'],
|
||||
pdata[p]['street3Bets'],
|
||||
pdata[p]['street4Bets'],
|
||||
) )
|
||||
|
||||
q = """INSERT INTO HandsPlayers (
|
||||
|
@ -1403,19 +1427,46 @@ class Database:
|
|||
playerId,
|
||||
startCash,
|
||||
seatNo,
|
||||
card1,
|
||||
card2,
|
||||
card3,
|
||||
card4,
|
||||
card5,
|
||||
card6,
|
||||
card7,
|
||||
winnings,
|
||||
rake,
|
||||
totalProfit,
|
||||
street0VPI,
|
||||
street1Seen,
|
||||
street2Seen,
|
||||
street3Seen,
|
||||
street4Seen,
|
||||
sawShowdown,
|
||||
wonAtSD,
|
||||
street0Aggr,
|
||||
street1Aggr,
|
||||
street2Aggr,
|
||||
street3Aggr,
|
||||
street4Aggr
|
||||
street4Aggr,
|
||||
wonWhenSeenStreet1,
|
||||
street0Calls,
|
||||
street1Calls,
|
||||
street2Calls,
|
||||
street3Calls,
|
||||
street4Calls,
|
||||
street0Bets,
|
||||
street1Bets,
|
||||
street2Bets,
|
||||
street3Bets,
|
||||
street4Bets
|
||||
)
|
||||
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, %s, %s, %s,
|
||||
%s, %s, %s, %s, %s
|
||||
|
@ -1423,16 +1474,9 @@ class Database:
|
|||
|
||||
# position,
|
||||
# tourneyTypeId,
|
||||
# card1,
|
||||
# card2,
|
||||
# card3,
|
||||
# card4,
|
||||
# startCards,
|
||||
# rake,
|
||||
# totalProfit,
|
||||
# street0_3BChance,
|
||||
# street0_3BDone,
|
||||
# sawShowdown,
|
||||
# otherRaisedStreet1,
|
||||
# otherRaisedStreet2,
|
||||
# otherRaisedStreet3,
|
||||
|
@ -1441,8 +1485,6 @@ class Database:
|
|||
# foldToOtherRaisedStreet2,
|
||||
# foldToOtherRaisedStreet3,
|
||||
# foldToOtherRaisedStreet4,
|
||||
# wonWhenSeenStreet1,
|
||||
# wonAtSD,
|
||||
# stealAttemptChance,
|
||||
# stealAttempted,
|
||||
# foldBbToStealChance,
|
||||
|
@ -1473,21 +1515,13 @@ class Database:
|
|||
# street3CheckCallRaiseDone,
|
||||
# street4CheckCallRaiseChance,
|
||||
# street4CheckCallRaiseDone,
|
||||
# street0Calls,
|
||||
# street1Calls,
|
||||
# street2Calls,
|
||||
# street3Calls,
|
||||
# street4Calls,
|
||||
# street0Bets,
|
||||
# street1Bets,
|
||||
# street2Bets,
|
||||
# street3Bets,
|
||||
# street4Bets
|
||||
|
||||
q = q.replace('%s', self.sql.query['placeholder'])
|
||||
|
||||
#print "DEBUG: inserts: %s" %inserts
|
||||
self.cursor.executemany(q, inserts)
|
||||
#print "DEBUG: q: %s" % q
|
||||
c = self.connection.cursor()
|
||||
c.executemany(q, inserts)
|
||||
|
||||
def storeHudCacheNew(self, gid, pid, hc):
|
||||
q = """INSERT INTO HudCache (
|
||||
|
|
|
@ -43,7 +43,7 @@ class DatabaseManager(gobject.GObject):
|
|||
import Options
|
||||
import Configuration
|
||||
#NOTE: fpdb should perform this globally
|
||||
(options, sys.argv) = Options.fpdb_options()
|
||||
(options, argv) = Options.fpdb_options()
|
||||
config = Configuration.Config(file=options.config, dbname=options.dbname)
|
||||
#TODO: handle no database present
|
||||
defaultDatabaseName = config.get_db_parameters().get('db-databaseName', None)
|
||||
|
@ -808,5 +808,3 @@ if __name__ == '__main__':
|
|||
d.connect("destroy", gtk.main_quit)
|
||||
d.run()
|
||||
#gtk.main()
|
||||
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#fpdb modules
|
||||
import Card
|
||||
|
||||
DEBUG = True
|
||||
DEBUG = False
|
||||
|
||||
if DEBUG:
|
||||
import pprint
|
||||
|
@ -39,8 +39,16 @@ class DerivedStats():
|
|||
#Init vars that may not be used, but still need to be inserted.
|
||||
# All stud street4 need this when importing holdem
|
||||
self.handsplayers[player[1]]['winnings'] = 0
|
||||
self.handsplayers[player[1]]['rake'] = 0
|
||||
self.handsplayers[player[1]]['totalProfit'] = 0
|
||||
self.handsplayers[player[1]]['street4Seen'] = False
|
||||
self.handsplayers[player[1]]['street4Aggr'] = False
|
||||
self.handsplayers[player[1]]['wonWhenSeenStreet1'] = False
|
||||
self.handsplayers[player[1]]['sawShowdown'] = False
|
||||
self.handsplayers[player[1]]['wonAtSD'] = False
|
||||
for i in range(5):
|
||||
self.handsplayers[player[1]]['street%dCalls' % i] = 0
|
||||
self.handsplayers[player[1]]['street%dBets' % i] = 0
|
||||
|
||||
self.assembleHands(self.hand)
|
||||
self.assembleHandsPlayers(self.hand)
|
||||
|
@ -81,12 +89,13 @@ class DerivedStats():
|
|||
self.hands['boardcard5'] = cards[4]
|
||||
|
||||
#print "DEBUG: self.getStreetTotals = (%s, %s, %s, %s, %s)" % hand.getStreetTotals()
|
||||
#FIXME: Pot size still in decimal, needs to be converted to cents
|
||||
(self.hands['street1Pot'],
|
||||
self.hands['street2Pot'],
|
||||
self.hands['street3Pot'],
|
||||
self.hands['street4Pot'],
|
||||
self.hands['showdownPot']) = hand.getStreetTotals()
|
||||
totals = hand.getStreetTotals()
|
||||
totals = [int(100*i) for i in totals]
|
||||
self.hands['street1Pot'] = totals[0]
|
||||
self.hands['street2Pot'] = totals[1]
|
||||
self.hands['street3Pot'] = totals[2]
|
||||
self.hands['street4Pot'] = totals[3]
|
||||
self.hands['showdownPot'] = totals[4]
|
||||
|
||||
self.vpip(hand) # Gives playersVpi (num of players vpip)
|
||||
#print "DEBUG: vpip: %s" %(self.hands['playersVpi'])
|
||||
|
@ -94,27 +103,62 @@ class DerivedStats():
|
|||
#print "DEBUG: playersAtStreet 1:'%s' 2:'%s' 3:'%s' 4:'%s'" %(self.hands['playersAtStreet1'],self.hands['playersAtStreet2'],self.hands['playersAtStreet3'],self.hands['playersAtStreet4'])
|
||||
self.streetXRaises(hand) # Empty function currently
|
||||
|
||||
# comment TEXT,
|
||||
# commentTs DATETIME
|
||||
|
||||
def assembleHandsPlayers(self, hand):
|
||||
#street0VPI/vpip already called in Hand
|
||||
# sawShowdown is calculated in playersAtStreetX, as that calculation gives us a convenient list of names
|
||||
|
||||
#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]
|
||||
|
||||
# Winnings is a non-negative value of money collected from the pot, which already includes the
|
||||
# rake taken out. hand.collectees is Decimal, database requires cents
|
||||
for player in hand.collectees:
|
||||
self.handsplayers[player]['winnings'] = int(100 * hand.collectees[player])
|
||||
|
||||
for i, street in enumerate(hand.actionStreets[2:]):
|
||||
self.seen(self.hand, i+1)
|
||||
|
||||
for i, street in enumerate(hand.actionStreets[1:]):
|
||||
self.aggr(self.hand, i)
|
||||
self.calls(self.hand, i)
|
||||
self.bets(self.hand, i)
|
||||
|
||||
# Winnings is a non-negative value of money collected from the pot, which already includes the
|
||||
# rake taken out. hand.collectees is Decimal, database requires cents
|
||||
for player in hand.collectees:
|
||||
self.handsplayers[player]['winnings'] = int(100 * hand.collectees[player])
|
||||
#FIXME: This is pretty dodgy, rake = hand.rake/#collectees
|
||||
# You can really only pay rake when you collect money, but
|
||||
# different sites calculate rake differently.
|
||||
# Should be fine for split-pots, but won't be accurate for multi-way pots
|
||||
self.handsplayers[player]['rake'] = int(100* hand.rake)/len(hand.collectees)
|
||||
if self.handsplayers[player]['street1Seen'] == True:
|
||||
self.handsplayers[player]['wonWhenSeenStreet1'] = True
|
||||
if self.handsplayers[player]['sawShowdown'] == True:
|
||||
self.handsplayers[player]['wonAtSD'] = True
|
||||
|
||||
for player in hand.pot.committed:
|
||||
self.handsplayers[player]['totalProfit'] = int(self.handsplayers[player]['winnings'] - (100*hand.pot.committed[player]))
|
||||
|
||||
#default_holecards = ["Xx", "Xx", "Xx", "Xx"]
|
||||
#if hand.gametype['base'] == "hold":
|
||||
# pass
|
||||
#elif hand.gametype['base'] == "stud":
|
||||
# pass
|
||||
#else:
|
||||
# # Flop hopefully...
|
||||
# pass
|
||||
|
||||
for street in hand.holeStreets:
|
||||
for player in hand.players:
|
||||
for i in range(1,8): self.handsplayers[player[1]]['card%d' % i] = 0
|
||||
#print "DEBUG: hand.holecards[%s]: %s" % (street, hand.holecards[street])
|
||||
if player[1] in hand.holecards[street].keys() and hand.gametype['base'] == "hold":
|
||||
self.handsplayers[player[1]]['card1'] = Card.encodeCard(hand.holecards[street][player[1]][1][0])
|
||||
self.handsplayers[player[1]]['card2'] = Card.encodeCard(hand.holecards[street][player[1]][1][1])
|
||||
try:
|
||||
self.handsplayers[player[1]]['card3'] = Card.encodeCard(hand.holecards[street][player[1]][1][2])
|
||||
self.handsplayers[player[1]]['card4'] = Card.encodeCard(hand.holecards[street][player[1]][1][3])
|
||||
except IndexError:
|
||||
# Just means no player cards for that street/game - continue
|
||||
pass
|
||||
|
||||
def assembleHudCache(self, hand):
|
||||
pass
|
||||
|
@ -147,14 +191,23 @@ class DerivedStats():
|
|||
self.hands['playersAtStreet4'] = 0
|
||||
self.hands['playersAtShowdown'] = 0
|
||||
|
||||
alliners = set()
|
||||
for (i, street) in enumerate(hand.actionStreets[2:]):
|
||||
actors = {}
|
||||
for act in hand.actions[street]:
|
||||
actors[act[0]] = 1
|
||||
self.hands['playersAtStreet%s' % str(i+1)] = len(actors.keys())
|
||||
actors = set()
|
||||
for action in hand.actions[street]:
|
||||
if len(action) > 2 and action[-1]: # allin
|
||||
alliners.add(action[0])
|
||||
actors.add(action[0])
|
||||
if len(actors)==0 and len(alliners)<2:
|
||||
alliners = set()
|
||||
self.hands['playersAtStreet%d' % (i+1)] = len(set.union(alliners, actors))
|
||||
|
||||
#Need playersAtShowdown
|
||||
actions = hand.actions[hand.actionStreets[-1]]
|
||||
pas = set.union(self.pfba(actions) - self.pfba(actions, l=('folds',)), alliners)
|
||||
self.hands['playersAtShowdown'] = len(pas)
|
||||
|
||||
for player in pas:
|
||||
self.handsplayers[player]['sawShowdown'] = True
|
||||
|
||||
def streetXRaises(self, hand):
|
||||
# self.actions[street] is a list of all actions in a tuple, contining the action as the second element
|
||||
|
@ -162,11 +215,11 @@ class DerivedStats():
|
|||
# No idea what this value is actually supposed to be
|
||||
# In theory its "num small bets paid to see flop/street4, including blind" which makes sense for limit. Not so useful for nl
|
||||
# Leaving empty for the moment,
|
||||
self.hands['street0Raises'] = 0 # /* num small bets paid to see flop/street4, including blind */
|
||||
self.hands['street1Raises'] = 0 # /* num small bets paid to see turn/street5 */
|
||||
self.hands['street2Raises'] = 0 # /* num big bets paid to see river/street6 */
|
||||
self.hands['street3Raises'] = 0 # /* num big bets paid to see sd/street7 */
|
||||
self.hands['street4Raises'] = 0 # /* num big bets paid to see showdown */
|
||||
|
||||
for i in range(5): self.hands['street%dRaises' % i] = 0
|
||||
|
||||
for (i, street) in enumerate(hand.actionStreets[1:]):
|
||||
self.hands['street%dRaises' % i] = len(filter( lambda action: action[1] in ('raises','bets'), hand.actions[street]))
|
||||
|
||||
def seen(self, hand, i):
|
||||
pas = set()
|
||||
|
@ -191,5 +244,32 @@ class DerivedStats():
|
|||
else:
|
||||
self.handsplayers[player[1]]['street%sAggr' % i] = False
|
||||
|
||||
def calls(self, hand, i):
|
||||
callers = []
|
||||
for act in hand.actions[hand.actionStreets[i+1]]:
|
||||
if act[1] in ('calls'):
|
||||
self.handsplayers[act[0]]['street%sCalls' % i] = 1 + self.handsplayers[act[0]]['street%sCalls' % i]
|
||||
|
||||
# CG - I'm sure this stat is wrong
|
||||
# Best guess is that raise = 2 bets
|
||||
def bets(self, hand, i):
|
||||
betters = []
|
||||
for act in hand.actions[hand.actionStreets[i+1]]:
|
||||
if act[1] in ('bets'):
|
||||
self.handsplayers[act[0]]['street%sBets' % i] = 1 + self.handsplayers[act[0]]['street%sBets' % i]
|
||||
|
||||
def countPlayers(self, hand):
|
||||
pass
|
||||
|
||||
def pfba(self, actions, f=None, l=None):
|
||||
"""Helper method. Returns set of PlayersFilteredByActions
|
||||
|
||||
f - forbidden actions
|
||||
l - limited to actions
|
||||
"""
|
||||
players = set()
|
||||
for action in actions:
|
||||
if l is not None and action[1] not in l: continue
|
||||
if f is not None and action[1] in f: continue
|
||||
players.add(action[0])
|
||||
return players
|
||||
|
|
|
@ -17,8 +17,15 @@ class FpdbParseError(FpdbError):
|
|||
class FpdbDatabaseError(FpdbError):
|
||||
pass
|
||||
|
||||
class FpdbMySQLFailedError(FpdbDatabaseError):
|
||||
class FpdbMySQLError(FpdbDatabaseError):
|
||||
pass
|
||||
|
||||
class FpdbMySQLAccessDenied(FpdbDatabaseError):
|
||||
def __init__(self, value='', errmsg=''):
|
||||
self.value = value
|
||||
self.errmsg = errmsg
|
||||
def __str__(self):
|
||||
return repr(self.value +" " + self.errmsg)
|
||||
|
||||
class DuplicateError(FpdbError):
|
||||
pass
|
||||
|
|
|
@ -733,7 +733,7 @@ def main(argv=None):
|
|||
gtk.main_quit()
|
||||
|
||||
parser = OptionParser()
|
||||
(options, sys.argv) = parser.parse_args(args = argv)
|
||||
(options, argv) = parser.parse_args(args = argv)
|
||||
|
||||
config = Configuration.Config()
|
||||
db = None
|
||||
|
@ -752,5 +752,3 @@ def main(argv=None):
|
|||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
||||
|
||||
|
|
|
@ -281,7 +281,7 @@ if __name__== "__main__":
|
|||
parser.add_option("-q", "--quiet", action="store_false", dest="gui", default=True, help="don't start gui")
|
||||
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)")
|
||||
(options, sys.argv) = parser.parse_args()
|
||||
(options, argv) = parser.parse_args()
|
||||
|
||||
config = Configuration.Config()
|
||||
# db = fpdb_db.fpdb_db()
|
||||
|
@ -305,4 +305,3 @@ if __name__== "__main__":
|
|||
gtk.main()
|
||||
else:
|
||||
pass
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ def main(argv=None):
|
|||
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, argv) = parser.parse_args(args = argv)
|
||||
|
||||
if options.usage == True:
|
||||
#Print usage examples and exit
|
||||
|
@ -377,4 +377,3 @@ def main(argv=None):
|
|||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import os
|
|||
import Options
|
||||
import traceback
|
||||
|
||||
(options, sys.argv) = Options.fpdb_options()
|
||||
(options, argv) = Options.fpdb_options()
|
||||
|
||||
if not options.errorsToConsole:
|
||||
print "Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_."
|
||||
|
|
|
@ -94,7 +94,7 @@ follow : whether to tail -f the input"""
|
|||
else:
|
||||
log.info("Created directory '%s'" % out_dir)
|
||||
try:
|
||||
self.out_fh = codecs.open(self.out_path, 'w', 'cp1252')
|
||||
self.out_fh = codecs.open(self.out_path, 'w', 'utf8')
|
||||
except:
|
||||
log.error("out_path %s couldn't be opened" % (self.out_path))
|
||||
else:
|
||||
|
|
|
@ -35,11 +35,11 @@ def fpdb_options():
|
|||
parser.add_option("-r", "--rerunPython",
|
||||
action="store_true",
|
||||
help="Indicates program was restarted with a different path (only allowed once).")
|
||||
(options, sys.argv) = parser.parse_args()
|
||||
return (options, sys.argv)
|
||||
(options, argv) = parser.parse_args()
|
||||
return (options, argv)
|
||||
|
||||
if __name__== "__main__":
|
||||
(options, sys.argv) = fpdb_options()
|
||||
(options, argv) = fpdb_options()
|
||||
print "errorsToConsole =", options.errorsToConsole
|
||||
print "database name =", options.dbname
|
||||
print "config file =", options.config
|
||||
|
|
|
@ -31,18 +31,18 @@ class PokerStars(HandHistoryConverter):
|
|||
|
||||
sitename = "PokerStars"
|
||||
filetype = "text"
|
||||
codepage = "cp1252"
|
||||
codepage = ("utf8", "cp1252")
|
||||
siteId = 2 # Needs to match id entry in Sites database
|
||||
|
||||
mixes = { 'HORSE': 'horse', '8-Game': '8game', 'HOSE': 'hose'} # Legal mixed games
|
||||
sym = {'USD': "\$", 'CAD': "\$", 'T$': "", "EUR": "\x80", "GBP": "\xa3"} # ADD Euro, Sterling, etc HERE
|
||||
sym = {'USD': "\$", 'CAD': "\$", 'T$': "", "EUR": "\xe2\x82\xac", "GBP": "\xa3"} # ADD Euro, Sterling, etc HERE
|
||||
substitutions = {
|
||||
'LEGAL_ISO' : "USD|EUR|GBP|CAD|FPP", # legal ISO currency codes
|
||||
'LS' : "\$|\x80|\xa3" # legal currency symbols ADD Euro, Sterling, etc HERE
|
||||
'LS' : "\$|\xe2\x82\xac|" # legal currency symbols - Euro(cp1252, utf-8)
|
||||
}
|
||||
|
||||
# Static regexes
|
||||
re_GameInfo = re.compile("""
|
||||
re_GameInfo = re.compile(u"""
|
||||
PokerStars\sGame\s\#(?P<HID>[0-9]+):\s+
|
||||
(Tournament\s\# # open paren of tournament info
|
||||
(?P<TOURNO>\d+),\s
|
||||
|
@ -62,7 +62,7 @@ class PokerStars(HandHistoryConverter):
|
|||
(?P<DATETIME>.*$)""" % substitutions,
|
||||
re.MULTILINE|re.VERBOSE)
|
||||
|
||||
re_PlayerInfo = re.compile("""
|
||||
re_PlayerInfo = re.compile(u"""
|
||||
^Seat\s(?P<SEAT>[0-9]+):\s
|
||||
(?P<PNAME>.*)\s
|
||||
\((%(LS)s)?(?P<CASH>[.0-9]+)\sin\schips\)""" % substitutions,
|
||||
|
@ -373,12 +373,9 @@ if __name__ == "__main__":
|
|||
parser.add_option("-i", "--input", dest="ipath", help="parse input hand history", default="regression-test-files/stars/horse/HH20090226 Natalie V - $0.10-$0.20 - HORSE.txt")
|
||||
parser.add_option("-o", "--output", dest="opath", help="output translation to", default="-")
|
||||
parser.add_option("-f", "--follow", dest="follow", help="follow (tail -f) the input", action="store_true", default=False)
|
||||
parser.add_option("-q", "--quiet",
|
||||
action="store_const", const=logging.CRITICAL, dest="verbosity", default=logging.INFO)
|
||||
parser.add_option("-v", "--verbose",
|
||||
action="store_const", const=logging.INFO, dest="verbosity")
|
||||
parser.add_option("--vv",
|
||||
action="store_const", const=logging.DEBUG, dest="verbosity")
|
||||
#parser.add_option("-q", "--quiet", action="store_const", const=logging.CRITICAL, dest="verbosity", default=logging.INFO)
|
||||
#parser.add_option("-v", "--verbose", action="store_const", const=logging.INFO, dest="verbosity")
|
||||
#parser.add_option("--vv", action="store_const", const=logging.DEBUG, dest="verbosity")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import os
|
|||
import Options
|
||||
import traceback
|
||||
|
||||
(options, sys.argv) = Options.fpdb_options()
|
||||
(options, argv) = Options.fpdb_options()
|
||||
|
||||
if not options.errorsToConsole:
|
||||
print "Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_."
|
||||
|
|
|
@ -53,7 +53,7 @@ import threading
|
|||
import Options
|
||||
import string
|
||||
cl_options = string.join(sys.argv[1:])
|
||||
(options, sys.argv) = Options.fpdb_options()
|
||||
(options, argv) = Options.fpdb_options()
|
||||
|
||||
if not options.errorsToConsole:
|
||||
print "Note: error output is being diverted to fpdb-error-log.txt and HUD-error.txt. Any major error will be reported there _only_."
|
||||
|
@ -80,7 +80,7 @@ import SQL
|
|||
import Database
|
||||
import FpdbSQLQueries
|
||||
import Configuration
|
||||
from Exceptions import *
|
||||
import Exceptions
|
||||
|
||||
VERSION = "0.12"
|
||||
|
||||
|
@ -453,21 +453,25 @@ class fpdb:
|
|||
self.sql = SQL.Sql(db_server = self.settings['db-server'])
|
||||
try:
|
||||
self.db = Database.Database(self.config, sql = self.sql)
|
||||
except FpdbMySQLFailedError:
|
||||
self.warning_box("Unable to connect to MySQL! Is the MySQL server running?!", "FPDB ERROR")
|
||||
except Exceptions.FpdbMySQLAccessDenied:
|
||||
self.warning_box("MySQL Server reports: Access denied. Are your permissions set correctly?")
|
||||
exit()
|
||||
except FpdbError:
|
||||
#print "Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user'])
|
||||
self.warning_box("Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user']), "FPDB ERROR")
|
||||
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||
print "*** Error: " + err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1])
|
||||
sys.stderr.write("Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user']))
|
||||
except:
|
||||
#print "Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user'])
|
||||
self.warning_box("Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user']), "FPDB ERROR")
|
||||
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||
print "*** Error: " + err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1])
|
||||
sys.stderr.write("Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user']))
|
||||
|
||||
# except FpdbMySQLFailedError:
|
||||
# self.warning_box("Unable to connect to MySQL! Is the MySQL server running?!", "FPDB ERROR")
|
||||
# exit()
|
||||
# except FpdbError:
|
||||
# #print "Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user'])
|
||||
# self.warning_box("Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user']), "FPDB ERROR")
|
||||
# err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||
# print "*** Error: " + err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1])
|
||||
# sys.stderr.write("Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user']))
|
||||
# except:
|
||||
# #print "Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user'])
|
||||
# self.warning_box("Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user']), "FPDB ERROR")
|
||||
# err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||
# print "*** Error: " + err[2] + "(" + str(err[1]) + "): " + str(sys.exc_info()[1])
|
||||
# sys.stderr.write("Failed to connect to %s database with username %s." % (self.settings['db-server'], self.settings['db-user']))
|
||||
|
||||
if self.db.wrongDbVersion:
|
||||
diaDbVersionWarning = gtk.Dialog(title="Strong Warning - Invalid database version", parent=None, flags=0, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK))
|
||||
|
|
|
@ -100,11 +100,14 @@ class fpdb_db:
|
|||
import MySQLdb
|
||||
if use_pool:
|
||||
MySQLdb = pool.manage(MySQLdb, pool_size=5)
|
||||
# try:
|
||||
try:
|
||||
self.db = MySQLdb.connect(host=host, user=user, passwd=password, db=database, use_unicode=True)
|
||||
#TODO: Add port option
|
||||
# except:
|
||||
# raise FpdbMySQLFailedError("MySQL connection failed")
|
||||
except MySQLdb.Error, ex:
|
||||
if ex.args[0] == 1045:
|
||||
raise FpdbMySQLAccessDenied(ex.args[0], ex.args[1])
|
||||
else:
|
||||
print "*** WARNING UNKNOWN MYSQL ERROR", ex
|
||||
elif backend == fpdb_db.PGSQL:
|
||||
import psycopg2
|
||||
import psycopg2.extensions
|
||||
|
|
Loading…
Reference in New Issue
Block a user