aptofpdb: remove debugging print

guiautoimport: import traceback
fpdb_simple/GuiPlayerStats: deal with multiple sites with players with matching names
HUD_main: error file is again HUD-error not fpdb-error-log.
This commit is contained in:
eblade 2009-08-06 07:23:57 -04:00
parent a7f857a90c
commit f65e4e005a
5 changed files with 19 additions and 7 deletions

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2008, Carl Gherardi
@ -60,7 +60,7 @@ debugging: if False, pass on partially supported game types. If true, have a go
logging.info("Initialising Absolute converter class")
self.filetype = "text"
self.codepage = "cp1252"
self.siteId = 5 # Needs to match id entry in Sites database
self.siteId = 8 # Needs to match id entry in Sites database
self.debugging = debugging
if autostart:
self.start()
@ -79,7 +79,7 @@ debugging: if False, pass on partially supported game types. If true, have a go
# TODO: Absolute posting when coming in new: %s - Posts $0.02 .. should that be a new Post line? where do we need to add support for that? *confused*
self.re_PostBoth = re.compile(ur"^%s - Posts dead (?:\$| €|)(?P<SBBB>[0-9]*[.0-9]+)" % player_re, re.MULTILINE)
self.re_Action = re.compile(ur"^%s - (?P<ATYPE>Bets |Raises |All-In |All-In\(Raise\) |Calls |Folds|Checks)?\$?(?P<BET>[0-9]*[.0-9]+)?" % player_re, re.MULTILINE)
print "^%s - (?P<ATYPE>Bets |Raises |All-In |All-In\(Raise\) |Calls |Folds|Checks)?\$?(?P<BET>[0-9]*[.0-9]+)?" % player_re
# print "^%s - (?P<ATYPE>Bets |Raises |All-In |All-In\(Raise\) |Calls |Folds|Checks)?\$?(?P<BET>[0-9]*[.0-9]+)?" % player_re
self.re_ShowdownAction = re.compile(ur"^%s - Shows \[(?P<CARDS>.*)\]" % player_re, re.MULTILINE)
self.re_CollectPot = re.compile(ur"^Seat [0-9]: %s(?: \(dealer\)| \(big blind\)| \(small blind\)|) (?:won|collected) Total \((?:\$| €|)(?P<POT>[0-9]*[.0-9]+)\)" % player_re, re.MULTILINE)
#self.re_PostSB = re.compile(ur"^%s: posts small blind \[(?:\$| €|) (?P<SB>[.0-9]+)" % player_re, re.MULTILINE)

View File

@ -17,6 +17,7 @@
import threading
import subprocess
import traceback
import pygtk
pygtk.require('2.0')

View File

@ -167,7 +167,9 @@ class GuiPlayerStats (threading.Thread):
for site in sites:
if sites[site] == True:
sitenos.append(siteids[site])
self.cursor.execute(self.sql.query['getPlayerId'], (heroes[site],))
# Nasty hack to deal with multiple sites + same player name -Eric
que = self.sql.query['getPlayerId'] + " AND siteId=%d" % siteids[site]
self.cursor.execute(que, (heroes[site],))
result = self.db.cursor.fetchall()
if len(result) == 1:
playerids.append(result[0][0])

View File

@ -37,7 +37,7 @@ import traceback
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_."
errorFile = open('fpdb-error-log.txt', 'w', 0)
errorFile = open('HUD-error.txt', 'w', 0)
sys.stderr = errorFile
import thread

View File

@ -991,19 +991,28 @@ def recogniseTourneyTypeId(cursor, siteId, buyin, fee, knockout, rebuyOrAddon):
# return result
def recognisePlayerIDs(cursor, names, site_id):
q = "SELECT name,id FROM Players WHERE name=%s" % " OR name=".join(["%s" for n in names])
# print "\nrecognisePlayerIDs names=",len(names),names
q = "SELECT name,id FROM Players WHERE siteid=%d and (name=%s)" % (site_id, " OR name=".join(["%s" for n in names]))
# print "q=",q
cursor.execute(q, names) # get all playerids by the names passed in
ids = dict(cursor.fetchall()) # convert to dict
# print "ids(1)=",len(ids),ids
if len(ids) != len(names):
notfound = [n for n in names if n not in ids] # make list of names not in database
# print "notfound=", notfound
if notfound: # insert them into database
cursor.executemany("INSERT INTO Players (name, siteId) VALUES (%s, "+str(site_id)+")", [(n,) for n in notfound])
q2 = "SELECT name,id FROM Players WHERE name=%s" % " OR name=".join(["%s" for n in notfound])
q2 = "SELECT name,id FROM Players WHERE siteid=%d and (name=%s)" % (site_id, " OR name=".join(["%s" for n in notfound]))
cursor.execute(q2, notfound) # get their new ids
tmp = cursor.fetchall()
# print "tmp=", tmp
for n,id in tmp: # put them all into the same dict
ids[n] = id
# return them in the SAME ORDER that they came in in the names argument, rather than the order they came out of the DB
# print "ids=",ids
# list = [ids[n] for n in names]
# print "list=",list
# print "\n"
return [ids[n] for n in names]
#end def recognisePlayerIDs