Merge branch 'master' of git://git.assembla.com/fpdb-sql
This commit is contained in:
commit
ef39f5858e
|
@ -41,7 +41,8 @@ class GuiPlayerStats (threading.Thread):
|
||||||
self.main_window = mainwin
|
self.main_window = mainwin
|
||||||
self.sql = querylist
|
self.sql = querylist
|
||||||
|
|
||||||
self.liststore = None
|
self.liststore = [] # gtk.ListStore[] stores the contents of the grids
|
||||||
|
self.listcols = [] # gtk.TreeViewColumn[][] stores the columns in the grids
|
||||||
|
|
||||||
self.MYSQL_INNODB = 2
|
self.MYSQL_INNODB = 2
|
||||||
self.PGSQL = 3
|
self.PGSQL = 3
|
||||||
|
@ -162,6 +163,8 @@ class GuiPlayerStats (threading.Thread):
|
||||||
def refreshStats(self, widget, data):
|
def refreshStats(self, widget, data):
|
||||||
try: self.stats_vbox.destroy()
|
try: self.stats_vbox.destroy()
|
||||||
except AttributeError: pass
|
except AttributeError: pass
|
||||||
|
self.liststore = []
|
||||||
|
self.listcols = []
|
||||||
#self.stats_vbox = gtk.VBox(False, 0)
|
#self.stats_vbox = gtk.VBox(False, 0)
|
||||||
self.stats_vbox = gtk.VPaned()
|
self.stats_vbox = gtk.VPaned()
|
||||||
self.stats_vbox.show()
|
self.stats_vbox.show()
|
||||||
|
@ -217,8 +220,10 @@ class GuiPlayerStats (threading.Thread):
|
||||||
# 3rd parameter passes extra flags, currently includes:
|
# 3rd parameter passes extra flags, currently includes:
|
||||||
# holecards - whether to display card breakdown (True/False)
|
# holecards - whether to display card breakdown (True/False)
|
||||||
# numhands - min number hands required when displaying all players
|
# numhands - min number hands required when displaying all players
|
||||||
flags = [False, self.filters.getNumHands()]
|
# gridnum - index for grid data structures
|
||||||
self.addTable(swin, 'playerDetailedStats', flags, playerids, sitenos, limits, type, seats, groups, dates)
|
flags = [False, self.filters.getNumHands(), 0]
|
||||||
|
self.addGrid(swin, 'playerDetailedStats', flags, playerids
|
||||||
|
,sitenos, limits, type, seats, groups, dates)
|
||||||
|
|
||||||
# Separator
|
# Separator
|
||||||
vbox2 = gtk.VBox(False, 0)
|
vbox2 = gtk.VBox(False, 0)
|
||||||
|
@ -236,7 +241,9 @@ class GuiPlayerStats (threading.Thread):
|
||||||
|
|
||||||
# Detailed table
|
# Detailed table
|
||||||
flags[0] = True
|
flags[0] = True
|
||||||
self.addTable(swin, 'playerDetailedStats', flags, playerids, sitenos, limits, type, seats, groups, dates)
|
flags[2] = 1
|
||||||
|
self.addGrid(swin, 'playerDetailedStats', flags, playerids
|
||||||
|
,sitenos, limits, type, seats, groups, dates)
|
||||||
|
|
||||||
self.db.rollback()
|
self.db.rollback()
|
||||||
print "Stats page displayed in %4.2f seconds" % (time() - starttime)
|
print "Stats page displayed in %4.2f seconds" % (time() - starttime)
|
||||||
|
@ -257,11 +264,12 @@ class GuiPlayerStats (threading.Thread):
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def sortnums(self, model, iter1, iter2, n):
|
def sortnums(self, model, iter1, iter2, nums):
|
||||||
try:
|
try:
|
||||||
ret = 0
|
ret = 0
|
||||||
a = self.liststore.get_value(iter1, n)
|
(n, grid) = nums
|
||||||
b = self.liststore.get_value(iter2, n)
|
a = self.liststore[grid].get_value(iter1, n)
|
||||||
|
b = self.liststore[grid].get_value(iter2, n)
|
||||||
if 'f' in self.cols_to_show[n][4]:
|
if 'f' in self.cols_to_show[n][4]:
|
||||||
try: a = float(a)
|
try: a = float(a)
|
||||||
except: a = 0.0
|
except: a = 0.0
|
||||||
|
@ -281,7 +289,7 @@ class GuiPlayerStats (threading.Thread):
|
||||||
ret = 0
|
ret = 0
|
||||||
else:
|
else:
|
||||||
ret = 1
|
ret = 1
|
||||||
#print "n =", n, "iter1[n] =", self.liststore.get_value(iter1,n), "iter2[n] =", self.liststore.get_value(iter2,n), "ret =", ret
|
#print "n =", n, "iter1[n] =", self.liststore[grid].get_value(iter1,n), "iter2[n] =", self.liststore[grid].get_value(iter2,n), "ret =", ret
|
||||||
except:
|
except:
|
||||||
err = traceback.extract_tb(sys.exc_info()[2])
|
err = traceback.extract_tb(sys.exc_info()[2])
|
||||||
print "***sortnums error: " + str(sys.exc_info()[1])
|
print "***sortnums error: " + str(sys.exc_info()[1])
|
||||||
|
@ -289,18 +297,19 @@ class GuiPlayerStats (threading.Thread):
|
||||||
|
|
||||||
return(ret)
|
return(ret)
|
||||||
|
|
||||||
def sortcols(self, col, n):
|
def sortcols(self, col, nums):
|
||||||
try:
|
try:
|
||||||
#This doesn't actually work yet - clicking heading in top section sorts bottom section :-(
|
#This doesn't actually work yet - clicking heading in top section sorts bottom section :-(
|
||||||
if col.get_sort_order() == gtk.SORT_ASCENDING:
|
(n, grid) = nums
|
||||||
|
if not col.get_sort_indicator() or col.get_sort_order() == gtk.SORT_ASCENDING:
|
||||||
col.set_sort_order(gtk.SORT_DESCENDING)
|
col.set_sort_order(gtk.SORT_DESCENDING)
|
||||||
else:
|
else:
|
||||||
col.set_sort_order(gtk.SORT_ASCENDING)
|
col.set_sort_order(gtk.SORT_ASCENDING)
|
||||||
self.liststore.set_sort_column_id(n, col.get_sort_order())
|
self.liststore[grid].set_sort_column_id(n, col.get_sort_order())
|
||||||
self.liststore.set_sort_func(n, self.sortnums, n)
|
self.liststore[grid].set_sort_func(n, self.sortnums, (n,grid))
|
||||||
for i in xrange(len(self.listcols)):
|
for i in xrange(len(self.listcols[grid])):
|
||||||
self.listcols[i].set_sort_indicator(False)
|
self.listcols[grid][i].set_sort_indicator(False)
|
||||||
self.listcols[n].set_sort_indicator(True)
|
self.listcols[grid][n].set_sort_indicator(True)
|
||||||
# use this listcols[col].set_sort_indicator(True)
|
# use this listcols[col].set_sort_indicator(True)
|
||||||
# to turn indicator off for other cols
|
# to turn indicator off for other cols
|
||||||
except:
|
except:
|
||||||
|
@ -308,12 +317,12 @@ class GuiPlayerStats (threading.Thread):
|
||||||
print "***sortcols error: " + str(sys.exc_info()[1])
|
print "***sortcols error: " + str(sys.exc_info()[1])
|
||||||
print "\n".join( [e[0]+':'+str(e[1])+" "+e[2] for e in err] )
|
print "\n".join( [e[0]+':'+str(e[1])+" "+e[2] for e in err] )
|
||||||
|
|
||||||
def addTable(self, vbox, query, flags, playerids, sitenos, limits, type, seats, groups, dates):
|
def addGrid(self, vbox, query, flags, playerids, sitenos, limits, type, seats, groups, dates):
|
||||||
counter = 0
|
counter = 0
|
||||||
row = 0
|
row = 0
|
||||||
sqlrow = 0
|
sqlrow = 0
|
||||||
if not flags: holecards = False
|
if not flags: holecards,grid = False,0
|
||||||
else: holecards = flags[0]
|
else: holecards,grid = flags[0],flags[2]
|
||||||
|
|
||||||
tmp = self.sql.query[query]
|
tmp = self.sql.query[query]
|
||||||
tmp = self.refineQuery(tmp, flags, playerids, sitenos, limits, type, seats, groups, dates)
|
tmp = self.refineQuery(tmp, flags, playerids, sitenos, limits, type, seats, groups, dates)
|
||||||
|
@ -325,8 +334,9 @@ class GuiPlayerStats (threading.Thread):
|
||||||
self.cols_to_show = [x for x in self.columns if x[colshow]]
|
self.cols_to_show = [x for x in self.columns if x[colshow]]
|
||||||
hgametypeid_idx = colnames.index('hgametypeid')
|
hgametypeid_idx = colnames.index('hgametypeid')
|
||||||
|
|
||||||
self.liststore = gtk.ListStore(*([str] * len(self.cols_to_show)))
|
assert len(self.liststore) == grid, "len(self.liststore)="+str(len(self.liststore))+" grid-1="+str(grid)
|
||||||
view = gtk.TreeView(model=self.liststore)
|
self.liststore.append( gtk.ListStore(*([str] * len(self.cols_to_show))) )
|
||||||
|
view = gtk.TreeView(model=self.liststore[grid])
|
||||||
view.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
|
view.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
|
||||||
#vbox.pack_start(view, expand=False, padding=3)
|
#vbox.pack_start(view, expand=False, padding=3)
|
||||||
vbox.add(view)
|
vbox.add(view)
|
||||||
|
@ -335,7 +345,8 @@ class GuiPlayerStats (threading.Thread):
|
||||||
textcell50.set_property('xalign', 0.5)
|
textcell50.set_property('xalign', 0.5)
|
||||||
numcell = gtk.CellRendererText()
|
numcell = gtk.CellRendererText()
|
||||||
numcell.set_property('xalign', 1.0)
|
numcell.set_property('xalign', 1.0)
|
||||||
self.listcols = []
|
assert len(self.listcols) == grid
|
||||||
|
self.listcols.append( [] )
|
||||||
|
|
||||||
# Create header row eg column: ("game", True, "Game", 0.0, "%s")
|
# Create header row eg column: ("game", True, "Game", 0.0, "%s")
|
||||||
for col, column in enumerate(self.cols_to_show):
|
for col, column in enumerate(self.cols_to_show):
|
||||||
|
@ -343,31 +354,33 @@ class GuiPlayerStats (threading.Thread):
|
||||||
s = [x for x in self.columns if x[colalias] == 'hand'][0][colheading]
|
s = [x for x in self.columns if x[colalias] == 'hand'][0][colheading]
|
||||||
else:
|
else:
|
||||||
s = column[colheading]
|
s = column[colheading]
|
||||||
self.listcols.append(gtk.TreeViewColumn(s))
|
self.listcols[grid].append(gtk.TreeViewColumn(s))
|
||||||
view.append_column(self.listcols[col])
|
view.append_column(self.listcols[grid][col])
|
||||||
if column[colformat] == '%s':
|
if column[colformat] == '%s':
|
||||||
if column[colxalign] == 0.0:
|
if column[colxalign] == 0.0:
|
||||||
self.listcols[col].pack_start(textcell, expand=True)
|
self.listcols[grid][col].pack_start(textcell, expand=True)
|
||||||
self.listcols[col].add_attribute(textcell, 'text', col)
|
self.listcols[grid][col].add_attribute(textcell, 'text', col)
|
||||||
|
cellrend = textcell
|
||||||
else:
|
else:
|
||||||
self.listcols[col].pack_start(textcell50, expand=True)
|
self.listcols[grid][col].pack_start(textcell50, expand=True)
|
||||||
self.listcols[col].add_attribute(textcell50, 'text', col)
|
self.listcols[grid][col].add_attribute(textcell50, 'text', col)
|
||||||
self.listcols[col].set_expand(True)
|
cellrend = textcell50
|
||||||
|
self.listcols[grid][col].set_expand(True)
|
||||||
else:
|
else:
|
||||||
self.listcols[col].pack_start(numcell, expand=True)
|
self.listcols[grid][col].pack_start(numcell, expand=True)
|
||||||
self.listcols[col].add_attribute(numcell, 'text', col)
|
self.listcols[grid][col].add_attribute(numcell, 'text', col)
|
||||||
self.listcols[col].set_expand(True)
|
self.listcols[grid][col].set_expand(True)
|
||||||
#self.listcols[col].set_alignment(column[colxalign]) # no effect?
|
cellrend = numcell
|
||||||
if holecards:
|
#self.listcols[grid][col].set_alignment(column[colxalign]) # no effect?
|
||||||
self.listcols[col].set_clickable(True)
|
self.listcols[grid][col].set_clickable(True)
|
||||||
self.listcols[col].connect("clicked", self.sortcols, col)
|
self.listcols[grid][col].connect("clicked", self.sortcols, (col,grid))
|
||||||
if col == 0:
|
if col == 0:
|
||||||
self.listcols[col].set_sort_order(gtk.SORT_DESCENDING)
|
self.listcols[grid][col].set_sort_order(gtk.SORT_DESCENDING)
|
||||||
self.listcols[col].set_sort_indicator(True)
|
self.listcols[grid][col].set_sort_indicator(True)
|
||||||
if column[coltype] == 'cash':
|
if column[coltype] == 'cash':
|
||||||
self.listcols[col].set_cell_data_func(numcell, self.ledger_style_render_func)
|
self.listcols[grid][col].set_cell_data_func(numcell, self.ledger_style_render_func)
|
||||||
else:
|
else:
|
||||||
self.listcols[col].set_cell_data_func(numcell, self.reset_style_render_func)
|
self.listcols[grid][col].set_cell_data_func(cellrend, self.reset_style_render_func)
|
||||||
|
|
||||||
rows = len(result) # +1 for title row
|
rows = len(result) # +1 for title row
|
||||||
|
|
||||||
|
@ -408,12 +421,12 @@ class GuiPlayerStats (threading.Thread):
|
||||||
treerow.append(column[colformat] % value)
|
treerow.append(column[colformat] % value)
|
||||||
else:
|
else:
|
||||||
treerow.append(' ')
|
treerow.append(' ')
|
||||||
iter = self.liststore.append(treerow)
|
iter = self.liststore[grid].append(treerow)
|
||||||
sqlrow += 1
|
sqlrow += 1
|
||||||
row += 1
|
row += 1
|
||||||
vbox.show_all()
|
vbox.show_all()
|
||||||
|
|
||||||
#end def addTable(self, query, vars, playerids, sitenos, limits, type, seats, groups, dates):
|
#end def addGrid(self, query, vars, playerids, sitenos, limits, type, seats, groups, dates):
|
||||||
|
|
||||||
def refineQuery(self, query, flags, playerids, sitenos, limits, type, seats, groups, dates):
|
def refineQuery(self, query, flags, playerids, sitenos, limits, type, seats, groups, dates):
|
||||||
having = ''
|
having = ''
|
||||||
|
|
|
@ -24,18 +24,22 @@ import os
|
||||||
import traceback
|
import traceback
|
||||||
from time import time, strftime, localtime
|
from time import time, strftime, localtime
|
||||||
try:
|
try:
|
||||||
|
calluse = not 'matplotlib' in sys.modules
|
||||||
import matplotlib
|
import matplotlib
|
||||||
|
if calluse:
|
||||||
matplotlib.use('GTK')
|
matplotlib.use('GTK')
|
||||||
from matplotlib.figure import Figure
|
from matplotlib.figure import Figure
|
||||||
from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
|
from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
|
||||||
from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar
|
from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar
|
||||||
from matplotlib.finance import candlestick2
|
from matplotlib.finance import candlestick2
|
||||||
|
|
||||||
from numpy import diff, nonzero, sum, cumsum, max, mina
|
from numpy import diff, nonzero, sum, cumsum, max, min
|
||||||
# from matplotlib.dates import DateFormatter, WeekdayLocator, HourLocator, \
|
# from matplotlib.dates import DateFormatter, WeekdayLocator, HourLocator, \
|
||||||
# DayLocator, MONDAY, timezone
|
# DayLocator, MONDAY, timezone
|
||||||
|
|
||||||
except:
|
except:
|
||||||
|
err = traceback.extract_tb(sys.exc_info()[2])[-1]
|
||||||
|
print "***Error: "+err[2]+"("+str(err[1])+"): "+str(sys.exc_info()[1])
|
||||||
print """Failed to load numpy in Session Viewer"""
|
print """Failed to load numpy in Session Viewer"""
|
||||||
print """This is of no consequence as the module currently doesn't do anything."""
|
print """This is of no consequence as the module currently doesn't do anything."""
|
||||||
|
|
||||||
|
|
|
@ -516,6 +516,8 @@ class fpdb:
|
||||||
print "Quitting normally"
|
print "Quitting normally"
|
||||||
#check if current settings differ from profile, if so offer to save or abort
|
#check if current settings differ from profile, if so offer to save or abort
|
||||||
self.db.disconnect()
|
self.db.disconnect()
|
||||||
|
# hide icon as it doesn't go away immediately in Windows - is this ok in Linux Eric?
|
||||||
|
self.statusIcon.set_visible(False)
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
|
|
||||||
def release_global_lock(self):
|
def release_global_lock(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user