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

Conflicts:
	pyfpdb/Database.py
	pyfpdb/fpdb_db.py
	pyfpdb/fpdb_save_to_db.py
This commit is contained in:
Ray 2009-06-09 14:01:15 -04:00
commit f3103cc82a
6 changed files with 32 additions and 49 deletions

View File

@ -26,8 +26,8 @@ Create and manage the database objects.
# Standard Library modules
import sys
import traceback
import string
from datetime import datetime, date, time, timedelta
import string
# pyGTK modules
@ -85,9 +85,9 @@ class Database:
sys.exit()
self.type = db_params['db-type']
self.db_server = c.supported_databases[db_name].db_server
self.sql = SQL.Sql(game = game, type = self.type, db_server = self.db_server)
self.connection.rollback()
self.sql = SQL.Sql(game = game, type = self.type)
self.connection.rollback()
# To add to config:
self.hud_style = 'T' # A=All-time
# S=Session
@ -177,7 +177,7 @@ class Database:
"""Get and return the community cards for the specified hand."""
cards = {}
c = self.connection.cursor()
c.execute(self.sql.query['get_common_cards'], (hand,))
c.execute(self.sql.query['get_common_cards'], [hand])
colnames = [desc[0] for desc in c.description]
for row in c.fetchall():
s_dict = {}
@ -325,8 +325,9 @@ if __name__=="__main__":
h = db_connection.get_last_hand()
print "last hand = ", h
hero = db_connection.get_player_id(c, 'Full Tilt Poker', 'PokerAscetic')
print "nutOmatic is id_player = %d" % hero
hero = db_connection.get_player_id(c, 'PokerStars', 'nutOmatic')
if hero:
print "nutOmatic is id_player = %d" % hero
stat_dict = db_connection.get_stats_from_hand(h)
for p in stat_dict.keys():

View File

@ -158,7 +158,7 @@ or None if we fail to get the info """
# 2008/11/10 3:58:52 ET
#TODO: Do conversion from GMT to ET
#TODO: Need some date functions to convert to different timezones (Date::Manip for perl rocked for this)
hand.starttime = time.strptime(m.group('DATETIME'), "%Y/%m/%d - %H:%M:%S")
hand.starttime = datetime.datetime.strptime(m.group('DATETIME'), "%Y/%m/%d - %H:%M:%S")
return
def readPlayerStacks(self, hand):

View File

@ -124,7 +124,7 @@ 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")
hand.starttime = datetime.datetime.strptime(m.group('DATETIME'), "%H:%M:%S ET - %Y/%m/%d")
hand.maxseats = 8 # assume 8-max until we see otherwise
if m.group('TABLEATTRIBUTES'):
m2 = re.search("(deep )?(\d+)( max)?", m.group('TABLEATTRIBUTES'))

View File

@ -172,27 +172,20 @@ class fpdb_db:
raise fpdb_simple.FpdbError("MySQL connection failed")
elif backend==self.PGSQL:
import psycopg2
import psycopg2.extensions
import psycopg2.extensions
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
# If DB connection is made over TCP, then the variables
# host, user and password are required
# print "host=%s user=%s pass=%s." % (host, user, password)
if self.host and self.user and self.password:
try:
self.db = psycopg2.connect(host = host,
user = user,
password = password,
database = database)
except:
raise fpdb_simple.FpdbError("PostgreSQL connection failed")
# For local domain-socket connections, only DB name is
# needed, and everything else is in fact undefined and/or
# flat out wrong
if self.host == "localhost" or self.host == "127.0.0.1":
self.db = psycopg2.connect(database = database)
else:
try:
self.db = psycopg2.connect(database = database)
except:
raise fpdb_simple.FpdbError("PostgreSQL connection failed")
self.db = psycopg2.connect(host = host,
user = user,
password = password,
database = database)
else:
raise fpdb_simple.FpdbError("unrecognised database backend:"+backend)
self.cursor=self.db.cursor()

View File

@ -26,13 +26,14 @@ MYSQL_INNODB = 2
PGSQL = 3
SQLITE = 4
fastStoreHudCache = False # set this to True to test the new storeHudCache routine
#fastStoreHudCache = False # set this to True to test the new storeHudCache routine
#
#saveActions = True # 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
# # no graphs
saveActions = True # 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
# : No graphs
#stores a stud/razz hand into the database
def ring_stud(config, backend, db, cursor, base, category, site_hand_no, gametype_id, hand_start_time
,names, player_ids, start_cashes, antes, card_values, card_suits, winnings, rakes

View File

@ -16,24 +16,12 @@ def testPokerStarsHHDate():
datetime.datetime(2008,9,7,11,23,14))
)
def testFullTiltHHDate():
sitngo1 = "Full Tilt Poker Game #10311865543: $1 + $0.25 Sit & Go (78057629), Table 1 - 25/50 - No Limit Hold'em - 0:07:45 ET - 2009/01/29"
cash1 = "Full Tilt Poker Game #9403951181: Table CR - tay - $0.05/$0.10 - No Limit Hold'em - 9:40:20 ET - 2008/12/09"
cash2 = "Full Tilt Poker Game #9468383505: Table Bike (deep 6) - $0.05/$0.10 - No Limit Hold'em - 5:09:36 ET - 2008/12/13"
result = fpdb_simple.parseHandStartTime(sitngo1,"ftp")
assert result==datetime.datetime(2009,1,29,05,07,45)
result = fpdb_simple.parseHandStartTime(cash1,"ftp")
assert result==datetime.datetime(2008,12,9,14,40,20)
result = fpdb_simple.parseHandStartTime(cash2,"ftp")
assert result==datetime.datetime(2008,12,13,10,9,36)
def testTableDetection():
result = Tables.clean_title("French (deep)")
assert result == "French"
result = Tables.clean_title("French (deep) - $0.25/$0.50 - No Limit Hold'em - Logged In As xxxx")
assert result == "French"
for (header, site, result) in tuples:
yield checkDateParse, header, site, result
#def testTableDetection():
# result = Tables.clean_title("French (deep)")
# assert result == "French"
# result = Tables.clean_title("French (deep) - $0.25/$0.50 - No Limit Hold'em - Logged In As xxxx")
# assert result == "French"
#
# for (header, site, result) in tuples:
# yield checkDateParse, header, site, result