Merge branch 'master' of git://git.assembla.com/fpdb-sql
This commit is contained in:
commit
c32f95ebf3
|
@ -412,6 +412,7 @@ class Import:
|
|||
self.interval = node.getAttribute("interval")
|
||||
self.callFpdbHud = node.getAttribute("callFpdbHud")
|
||||
self.hhArchiveBase = node.getAttribute("hhArchiveBase")
|
||||
self.hhBulkPath = node.getAttribute("hhBulkPath")
|
||||
self.saveActions = string_to_bool(node.getAttribute("saveActions"), default=True)
|
||||
self.fastStoreHudCache = string_to_bool(node.getAttribute("fastStoreHudCache"), default=False)
|
||||
self.saveStarsHH = string_to_bool(node.getAttribute("saveStarsHH"), default=False)
|
||||
|
@ -452,6 +453,24 @@ class Tv:
|
|||
return (" combinedStealFold = %s\n combined2B3B = %s\n combinedPostflop = %s\n" %
|
||||
(self.combinedStealFold, self.combined2B3B, self.combinedPostflop) )
|
||||
|
||||
class General(dict):
|
||||
def __init__(self):
|
||||
super(General, self).__init__()
|
||||
|
||||
def add_elements(self, node):
|
||||
# day_start - number n where 0.0 <= n < 24.0 representing start of day for user
|
||||
# e.g. user could set to 4.0 for day to start at 4am local time
|
||||
# [ HH_bulk_path was here - now moved to import section ]
|
||||
for (name, value) in node.attributes.items():
|
||||
log.debug("config.general: adding %s = %s" % (name,value))
|
||||
self[name] = value
|
||||
|
||||
def __str__(self):
|
||||
s = ""
|
||||
for k in self:
|
||||
s = s + " %s = %s\n" % (k, self[k])
|
||||
return(s)
|
||||
|
||||
class Config:
|
||||
def __init__(self, file = None, dbname = ''):
|
||||
# "file" is a path to an xml file with the fpdb/HUD configuration
|
||||
|
@ -506,7 +525,10 @@ class Config:
|
|||
self.popup_windows = {}
|
||||
self.db_selected = None # database the user would like to use
|
||||
self.tv = None
|
||||
self.general = General()
|
||||
|
||||
for gen_node in doc.getElementsByTagName("general"):
|
||||
self.general.add_elements(node=gen_node) # add/overwrite elements in self.general
|
||||
|
||||
# s_sites = doc.getElementsByTagName("supported_sites")
|
||||
for site_node in doc.getElementsByTagName("site"):
|
||||
|
@ -818,9 +840,14 @@ class Config:
|
|||
try: imp['interval'] = self.imp.interval
|
||||
except: imp['interval'] = 10
|
||||
|
||||
# hhArchiveBase is the temp store for part-processed hand histories - should be redundant eventually
|
||||
try: imp['hhArchiveBase'] = self.imp.hhArchiveBase
|
||||
except: imp['hhArchiveBase'] = "~/.fpdb/HandHistories/"
|
||||
|
||||
# hhBulkPath is the default location for bulk imports (if set)
|
||||
try: imp['hhBulkPath'] = self.imp.hhBulkPath
|
||||
except: imp['hhBulkPath'] = ""
|
||||
|
||||
try: imp['saveActions'] = self.imp.saveActions
|
||||
except: imp['saveActions'] = True
|
||||
|
||||
|
@ -839,6 +866,8 @@ class Config:
|
|||
path = os.path.expanduser(self.supported_sites[site].HH_path)
|
||||
assert(os.path.isdir(path) or os.path.isfile(path)) # maybe it should try another site?
|
||||
paths['hud-defaultPath'] = paths['bulkImport-defaultPath'] = path
|
||||
if self.imp.hhBulkPath:
|
||||
paths['bulkImport-defaultPath'] = self.imp.hhBulkPath
|
||||
except AssertionError:
|
||||
paths['hud-defaultPath'] = paths['bulkImport-defaultPath'] = "** ERROR DEFAULT PATH IN CONFIG DOES NOT EXIST **"
|
||||
return paths
|
||||
|
@ -987,6 +1016,9 @@ class Config:
|
|||
"""Join the fpdb path to filename."""
|
||||
return os.path.join(os.path.dirname(inspect.getfile(sys._getframe(0))), filename)
|
||||
|
||||
def get_general_params(self):
|
||||
return( self.general )
|
||||
|
||||
if __name__== "__main__":
|
||||
c = Config()
|
||||
|
||||
|
|
|
@ -58,6 +58,11 @@ class Filters(threading.Thread):
|
|||
,'limitsFL':'FL', 'limitsNL':'NL', 'limitsPL':'PL', 'ring':'Ring', 'tour':'Tourney'
|
||||
}
|
||||
|
||||
gen = self.conf.get_general_params()
|
||||
self.day_start = 0
|
||||
if 'day_start' in gen:
|
||||
self.day_start = float(gen['day_start'])
|
||||
|
||||
# Outer Packing box
|
||||
self.mainVBox = gtk.VBox(False, 0)
|
||||
|
||||
|
@ -864,6 +869,9 @@ class Filters(threading.Thread):
|
|||
self.end_date.set_text('')
|
||||
|
||||
def __get_dates(self):
|
||||
# self.day_start gives user's start of day in hours
|
||||
offset = int(self.day_start * 3600) # calc day_start in seconds
|
||||
|
||||
t1 = self.start_date.get_text()
|
||||
t2 = self.end_date.get_text()
|
||||
|
||||
|
@ -872,7 +880,17 @@ class Filters(threading.Thread):
|
|||
if t2 == '':
|
||||
t2 = '2020-12-12'
|
||||
|
||||
return (t1, t2)
|
||||
s1 = strptime(t1, "%Y-%m-%d") # make time_struct
|
||||
s2 = strptime(t2, "%Y-%m-%d")
|
||||
e1 = mktime(s1) + offset # s1 is localtime, but returned time since epoch is UTC, then add the
|
||||
e2 = mktime(s2) + offset # s2 is localtime, but returned time since epoch is UTC
|
||||
e2 = e2 + 24 * 3600 - 1 # date test is inclusive, so add 23h 59m 59s to e2
|
||||
|
||||
adj_t1 = strftime("%Y-%m-%d %H:%M:%S", gmtime(e1)) # make adjusted string including time
|
||||
adj_t2 = strftime("%Y-%m-%d %H:%M:%S", gmtime(e2))
|
||||
log.info("t1="+t1+" adj_t1="+adj_t1+'.')
|
||||
|
||||
return (adj_t1, adj_t2)
|
||||
|
||||
def __get_date(self, widget, calendar, entry, win):
|
||||
# year and day are correct, month is 0..11
|
||||
|
|
|
@ -81,7 +81,7 @@ class GuiPlayerStats (threading.Thread):
|
|||
self.filters = Filters.Filters(self.db, self.conf, self.sql, display = filters_display)
|
||||
self.filters.registerButton1Name("_Filters")
|
||||
self.filters.registerButton1Callback(self.showDetailFilter)
|
||||
self.filters.registerButton2Name("_Refresh")
|
||||
self.filters.registerButton2Name("_Refresh Stats")
|
||||
self.filters.registerButton2Callback(self.refreshStats)
|
||||
|
||||
# ToDo: store in config
|
||||
|
@ -567,7 +567,7 @@ class GuiPlayerStats (threading.Thread):
|
|||
query = query.replace("<orderbyhgameTypeId>", "")
|
||||
groupLevels = "show" not in str(limits)
|
||||
if groupLevels:
|
||||
query = query.replace("<hgameTypeId>", "-1")
|
||||
query = query.replace("<hgameTypeId>", "p.name") # need to use p.name for sqlite posn stats to work
|
||||
else:
|
||||
query = query.replace("<hgameTypeId>", "h.gameTypeId")
|
||||
|
||||
|
|
|
@ -82,6 +82,8 @@ class PokerStars(HandHistoryConverter):
|
|||
# self.re_setHandInfoRegex('.*#(?P<HID>[0-9]+): Table (?P<TABLE>[ a-zA-Z]+) - \$?(?P<SB>[.0-9]+)/\$?(?P<BB>[.0-9]+) - (?P<GAMETYPE>.*) - (?P<HR>[0-9]+):(?P<MIN>[0-9]+) ET - (?P<YEAR>[0-9]+)/(?P<MON>[0-9]+)/(?P<DAY>[0-9]+)Table (?P<TABLE>[ a-zA-Z]+)\nSeat (?P<BUTTON>[0-9]+)')
|
||||
|
||||
re_DateTime = re.compile("""(?P<Y>[0-9]{4})\/(?P<M>[0-9]{2})\/(?P<D>[0-9]{2})[\- ]+(?P<H>[0-9]+):(?P<MIN>[0-9]+):(?P<S>[0-9]+)""", re.MULTILINE)
|
||||
# revised re including timezone (not currently used):
|
||||
#re_DateTime = re.compile("""(?P<Y>[0-9]{4})\/(?P<M>[0-9]{2})\/(?P<D>[0-9]{2})[\- ]+(?P<H>[0-9]+):(?P<MIN>[0-9]+):(?P<S>[0-9]+) \(?(?P<TZ>[A-Z0-9]+)""", re.MULTILINE)
|
||||
|
||||
def compilePlayerRegexs(self, hand):
|
||||
players = set([player[1] for player in hand.players])
|
||||
|
@ -206,14 +208,28 @@ class PokerStars(HandHistoryConverter):
|
|||
log.debug("readHandInfo: %s" % info)
|
||||
for key in info:
|
||||
if key == 'DATETIME':
|
||||
#2008/11/12 10:00:48 CET [2008/11/12 4:00:48 ET]
|
||||
#2008/11/12 10:00:48 CET [2008/11/12 4:00:48 ET] # (both dates are parsed so ET date overrides the other)
|
||||
#2008/08/17 - 01:14:43 (ET)
|
||||
#2008/09/07 06:23:14 ET
|
||||
m1 = self.re_DateTime.finditer(info[key])
|
||||
# m2 = re.search("(?P<Y>[0-9]{4})\/(?P<M>[0-9]{2})\/(?P<D>[0-9]{2})[\- ]+(?P<H>[0-9]+):(?P<MIN>[0-9]+):(?P<S>[0-9]+)", info[key])
|
||||
datetimestr = "2000/01/01 00:00:00" # default used if time not found (stops import crashing, but handstart will be wrong)
|
||||
for a in m1:
|
||||
datetimestr = "%s/%s/%s %s:%s:%s" % (a.group('Y'), a.group('M'),a.group('D'),a.group('H'),a.group('MIN'),a.group('S'))
|
||||
hand.starttime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S")
|
||||
#tz = a.group('TZ') # just assume ET??
|
||||
#print " tz = ", tz, " datetime =", datetimestr
|
||||
hand.starttime = datetime.datetime.strptime(datetimestr, "%Y/%m/%d %H:%M:%S") # also timezone at end, e.g. " ET"
|
||||
# approximate rules for ET daylight savings time:
|
||||
if ( hand.starttime.month == 12 # all of Dec
|
||||
or (hand.starttime.month == 11 and hand.starttime.day > 4) # and most of November
|
||||
or hand.starttime.month < 3 # and all of Jan/Feb
|
||||
or (hand.starttime.month == 3 and hand.starttime.day < 11) ): # and 1st 10 days of March
|
||||
offset = datetime.timedelta(hours=5) # are EST: assume 5 hour offset (ET without daylight saving)
|
||||
else:
|
||||
offset = datetime.timedelta(hours=4) # rest is EDT: assume 4 hour offset (ET with daylight saving)
|
||||
# adjust time into UTC:
|
||||
hand.starttime = hand.starttime + offset
|
||||
#print " tz = %s start = %s" % (tz, str(hand.starttime))
|
||||
if key == 'HID':
|
||||
hand.handid = info[key]
|
||||
if key == 'TOURNO':
|
||||
|
|
|
@ -1921,7 +1921,7 @@ class Sql:
|
|||
and h.seats <seats_test>
|
||||
<flagtest>
|
||||
<gtbigBlind_test>
|
||||
and date_format(h.handStart, '%Y-%m-%d') <datestest>
|
||||
and date_format(h.handStart, '%Y-%m-%d %T') <datestest>
|
||||
group by hgameTypeId
|
||||
,pname
|
||||
,gt.base
|
||||
|
@ -2006,7 +2006,7 @@ class Sql:
|
|||
and h.seats <seats_test>
|
||||
<flagtest>
|
||||
<gtbigBlind_test>
|
||||
and to_char(h.handStart, 'YYYY-MM-DD') <datestest>
|
||||
and to_char(h.handStart, 'YYYY-MM-DD HH24:MI:SS') <datestest>
|
||||
group by hgameTypeId
|
||||
,pname
|
||||
,gt.base
|
||||
|
@ -2092,7 +2092,7 @@ class Sql:
|
|||
and h.seats <seats_test>
|
||||
<flagtest>
|
||||
<gtbigBlind_test>
|
||||
and date(h.handStart) <datestest>
|
||||
and datetime(h.handStart) <datestest>
|
||||
group by hgameTypeId
|
||||
,hp.playerId
|
||||
,gt.base
|
||||
|
|
Loading…
Reference in New Issue
Block a user