From 014ddedc013dcb449596c2475b5744f664013291 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Sun, 7 Mar 2010 10:30:56 +0000 Subject: [PATCH 1/5] create db automatically if using sqlite --- pyfpdb/Database.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyfpdb/Database.py b/pyfpdb/Database.py index f51ce5f5..8939d4b3 100644 --- a/pyfpdb/Database.py +++ b/pyfpdb/Database.py @@ -382,6 +382,7 @@ class Database: print msg raise FpdbError(msg) elif backend == Database.SQLITE: + create = True import sqlite3 if use_pool: sqlite3 = pool.manage(sqlite3, pool_size=1) From 2e83e91ba53802c2a59a93c162d159df51778212 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Mon, 8 Mar 2010 22:31:07 +0000 Subject: [PATCH 2/5] add having clause to sqlite version of guistats query --- pyfpdb/SQL.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyfpdb/SQL.py b/pyfpdb/SQL.py index 51863698..b6eb8ee0 100644 --- a/pyfpdb/SQL.py +++ b/pyfpdb/SQL.py @@ -2099,6 +2099,7 @@ class Sql: ,plposition ,upper(gt.limitType) ,s.name + having 1 = 1 order by hp.playerId ,gt.base ,gt.category From 04acf25416e4f87e680eb38dce9efeba2fe8974d Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Mon, 8 Mar 2010 22:32:09 +0000 Subject: [PATCH 3/5] don't display headings for bottom table when it can't be calculated --- pyfpdb/GuiPlayerStats.py | 41 +++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index 3c3f46e3..a4bbdef1 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -208,6 +208,7 @@ class GuiPlayerStats (threading.Thread): def createStatsTable(self, vbox, playerids, sitenos, limits, type, seats, groups, dates, games): starttime = time() + show_detail = True # Scrolled window for summary table swin = gtk.ScrolledWindow(hadjustment=None, vadjustment=None) @@ -224,25 +225,30 @@ class GuiPlayerStats (threading.Thread): self.addGrid(swin, 'playerDetailedStats', flags, playerids ,sitenos, limits, type, seats, groups, dates, games) - # Separator - vbox2 = gtk.VBox(False, 0) - heading = gtk.Label(self.filterText['handhead']) - heading.show() - vbox2.pack_start(heading, expand=False, padding=3) + if 'allplayers' in groups and groups['allplayers']: + # can't currently do this combination so skip detailed table + show_detail = False - # Scrolled window for detailed table (display by hand) - swin = gtk.ScrolledWindow(hadjustment=None, vadjustment=None) - swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - swin.show() - vbox2.pack_start(swin, expand=True, padding=3) - vbox.pack2(vbox2) - vbox2.show() + if show_detail: + # Separator + vbox2 = gtk.VBox(False, 0) + heading = gtk.Label(self.filterText['handhead']) + heading.show() + vbox2.pack_start(heading, expand=False, padding=3) - # Detailed table - flags[0] = True - flags[2] = 1 - self.addGrid(swin, 'playerDetailedStats', flags, playerids - ,sitenos, limits, type, seats, groups, dates, games) + # Scrolled window for detailed table (display by hand) + swin = gtk.ScrolledWindow(hadjustment=None, vadjustment=None) + swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + swin.show() + vbox2.pack_start(swin, expand=True, padding=3) + vbox.pack2(vbox2) + vbox2.show() + + # Detailed table + flags[0] = True + flags[2] = 1 + self.addGrid(swin, 'playerDetailedStats', flags, playerids + ,sitenos, limits, type, seats, groups, dates, games) self.db.rollback() print "Stats page displayed in %4.2f seconds" % (time() - starttime) @@ -421,6 +427,7 @@ class GuiPlayerStats (threading.Thread): else: treerow.append(' ') iter = self.liststore[grid].append(treerow) + #print treerow sqlrow += 1 row += 1 vbox.show_all() From 6117eb64c8f30883bb0ca6d192b539157a497429 Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Mon, 8 Mar 2010 22:47:44 +0000 Subject: [PATCH 4/5] remember separator position when refresh is clicked --- pyfpdb/GuiPlayerStats.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index a4bbdef1..30bef936 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -142,7 +142,7 @@ class GuiPlayerStats (threading.Thread): self.stats_frame = gtk.Frame() self.stats_frame.show() - self.stats_vbox = gtk.VBox(False, 0) + self.stats_vbox = gtk.VPaned() self.stats_vbox.show() self.stats_frame.add(self.stats_vbox) # self.fillStatsFrame(self.stats_vbox) @@ -155,12 +155,15 @@ class GuiPlayerStats (threading.Thread): # make sure Hand column is not displayed [x for x in self.columns if x[0] == 'hand'][0][1] = False + self.last_pos = -1 + def get_vbox(self): """returns the vbox of this thread""" return self.main_hbox def refreshStats(self, widget, data): + self.last_pos = self.stats_vbox.get_position() try: self.stats_vbox.destroy() except AttributeError: pass self.liststore = [] @@ -170,6 +173,8 @@ class GuiPlayerStats (threading.Thread): self.stats_vbox.show() self.stats_frame.add(self.stats_vbox) self.fillStatsFrame(self.stats_vbox) + if self.last_pos > 0: + self.stats_vbox.set_position(self.last_pos) def fillStatsFrame(self, vbox): sites = self.filters.getSites() From a10f7c144ea8aa302cc73437b5126f3dce7220ef Mon Sep 17 00:00:00 2001 From: sqlcoder Date: Tue, 9 Mar 2010 22:36:03 +0000 Subject: [PATCH 5/5] allow log viewer to view all 4 log/error files --- pyfpdb/GuiLogView.py | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/pyfpdb/GuiLogView.py b/pyfpdb/GuiLogView.py index 9dcb9588..755e1762 100755 --- a/pyfpdb/GuiLogView.py +++ b/pyfpdb/GuiLogView.py @@ -33,6 +33,11 @@ log = logging.getLogger("logview") MAX_LINES = 100000 # max lines to display in window EST_CHARS_PER_LINE = 150 # used to guesstimate number of lines in log file +LOGFILES = [ [ 'Fpdb Errors', 'fpdb-errors.txt', False ] # label, filename, start value + , [ 'Fpdb Log', 'fpdb-log.txt', True ] + , [ 'HUD Errors', 'HUD-errors.txt', False ] + , [ 'HUD Log', 'HUD-log.txt', False ] + ] class GuiLogView: @@ -41,7 +46,7 @@ class GuiLogView: self.main_window = mainwin self.closeq = closeq - self.logfile = self.config.log_file # name of logfile + self.logfile = os.path.join(self.config.dir_log, LOGFILES[1][1]) self.dia = gtk.Dialog(title="Log Messages" ,parent=None ,flags=gtk.DIALOG_DESTROY_WITH_PARENT @@ -69,10 +74,19 @@ class GuiLogView: scrolledwindow.add(self.listview) self.vbox.pack_start(scrolledwindow, expand=True, fill=True, padding=0) + hb = gtk.HBox(False, 0) + grp = None + for logf in LOGFILES: + rb = gtk.RadioButton(group=grp, label=logf[0], use_underline=True) + if grp is None: grp = rb + rb.set_active(logf[2]) + rb.connect('clicked', self.__set_logfile, logf[0]) + hb.pack_start(rb, False, False, 3) refreshbutton = gtk.Button("Refresh") refreshbutton.connect("clicked", self.refresh, None) - self.vbox.pack_start(refreshbutton, False, False, 3) + hb.pack_start(refreshbutton, False, False, 3) refreshbutton.show() + self.vbox.pack_start(hb, False, False, 0) self.listview.show() scrolledwindow.show() @@ -90,6 +104,14 @@ class GuiLogView: self.dia.connect('response', self.dialog_response_cb) + def __set_logfile(self, w, file): + #print "w is", w, "file is", file, "active is", w.get_active() + if w.get_active(): + for logf in LOGFILES: + if logf[0] == file: + self.logfile = os.path.join(self.config.dir_log, logf[1]) + self.refresh(w, file) # params are not used + def dialog_response_cb(self, dialog, response_id): # this is called whether close button is pressed or window is closed self.closeq.put(self.__class__) @@ -131,11 +153,14 @@ class GuiLogView: l = 0 for line in open(self.logfile): - # eg line: + # example line in logfile format: # 2009-12-02 15:23:21,716 - config DEBUG config logger initialised l = l + 1 - if l > startline and len(line) > 49: - iter = self.liststore.append( (line[0:23], line[26:32], line[39:46], line[48:].strip(), True) ) + if l > startline: + if len(line) > 49 and line[23:26] == ' - ' and line[34:39] == ' ': + iter = self.liststore.append( (line[0:23], line[26:32], line[39:46], line[48:].strip(), True) ) + else: + iter = self.liststore.append( ('', '', '', line.strip(), True) ) def sortCols(self, col, n): try: