From bc15025be559ef1567a59306a8a5ac903d3f93bf Mon Sep 17 00:00:00 2001 From: steffen123 Date: Wed, 15 Oct 2008 18:20:33 +0100 Subject: [PATCH 1/4] p135 - updated tv --- ...b-1.0_alpha5_p110.ebuild => fpdb-1.0_alpha7_p135.ebuild} | 2 +- pyfpdb/CliFpdb.py | 1 + pyfpdb/GuiTableViewer.py | 6 ++++-- pyfpdb/fpdb.py | 2 +- pyfpdb/fpdb_import.py | 1 + pyfpdb/fpdb_simple.py | 4 +++- 6 files changed, 11 insertions(+), 5 deletions(-) rename packaging/gentoo/{fpdb-1.0_alpha5_p110.ebuild => fpdb-1.0_alpha7_p135.ebuild} (97%) diff --git a/packaging/gentoo/fpdb-1.0_alpha5_p110.ebuild b/packaging/gentoo/fpdb-1.0_alpha7_p135.ebuild similarity index 97% rename from packaging/gentoo/fpdb-1.0_alpha5_p110.ebuild rename to packaging/gentoo/fpdb-1.0_alpha7_p135.ebuild index 4e55238e..07fbb188 100644 --- a/packaging/gentoo/fpdb-1.0_alpha5_p110.ebuild +++ b/packaging/gentoo/fpdb-1.0_alpha7_p135.ebuild @@ -1,7 +1,7 @@ # Copyright 1999-2008 Gentoo Foundation # Gentoo had nothing to do with the production of this ebuild, but I'm pre-emptively transferring all copyrights (as far as legally possible under my local jurisdiction) to them. # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/games-util/fpdb/fpdb-1.0_alpha5_p110.ebuild,v 1.0 2008/09/26 steffen@sycamoretest.info Exp $ +# $Header: /var/cvsroot/gentoo-x86/games-util/fpdb/fpdb-1.0_alpha7_p135.ebuild,v 1.0 2008/10/15 steffen@sycamoretest.info Exp $ NEED_PYTHON=2.3 diff --git a/pyfpdb/CliFpdb.py b/pyfpdb/CliFpdb.py index 75dd1251..47649728 100755 --- a/pyfpdb/CliFpdb.py +++ b/pyfpdb/CliFpdb.py @@ -59,6 +59,7 @@ if __name__ == "__main__": settings['db-password']=options.password settings['db-databaseName']=options.database settings['handCount']=options.handCount + settings['failOnError']=options.failOnError importer = fpdb_import.Importer(options, settings) importer.addImportFile(options.inputFile) diff --git a/pyfpdb/GuiTableViewer.py b/pyfpdb/GuiTableViewer.py index f2bfecd9..1082bff1 100644 --- a/pyfpdb/GuiTableViewer.py +++ b/pyfpdb/GuiTableViewer.py @@ -220,7 +220,7 @@ class GuiTableViewer (threading.Thread): #print "start of table_viewer.read_names_clicked" self.db.reconnect() self.cursor=self.db.cursor - self.hands_id=self.last_read_hand_id + #self.hands_id=self.last_read_hand_id self.db.cursor.execute("SELECT gametypeId FROM Hands WHERE id=%s", (self.hands_id, )) self.gametype_id=self.db.cursor.fetchone()[0] @@ -257,7 +257,9 @@ class GuiTableViewer (threading.Thread): self.importer.setFailOnError(False) self.importer.setHandCount(0) - self.last_read_hand_id=self.importer.import_file_dict() + self.importer.addImportFile(self.inputFile) + self.importer.runImport() + self.hands_id=self.importer.handsId #end def table_viewer.import_clicked def all_clicked(self, widget, data): diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index e1440601..d3642bb5 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -426,7 +426,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) - self.window.set_title("Free Poker DB - version: alpha6+, p131 or higher") + self.window.set_title("Free Poker DB - version: alpha6+, p135 or higher") self.window.set_border_width(1) self.window.set_size_request(1020,400) self.window.set_resizable(True) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index b652f204..c622a526 100755 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -267,6 +267,7 @@ class Importer: handsId=0 #todo: this will cause return of an unstored hand number if the last hand was error or partial self.db.commit() + self.handsId=handsId return handsId #end def import_file_dict diff --git a/pyfpdb/fpdb_simple.py b/pyfpdb/fpdb_simple.py index 39de0c9e..217b9163 100644 --- a/pyfpdb/fpdb_simple.py +++ b/pyfpdb/fpdb_simple.py @@ -315,10 +315,12 @@ def filterAnteBlindFold(site,hand): #removes useless lines as well as trailing spaces def filterCrap(site, hand, isTourney): - #remove one trailing space at end of line + #remove two trailing spaces at end of line for i in range (len(hand)): if (hand[i][-1]==' '): hand[i]=hand[i][:-1] + if (hand[i][-1]==' '): + hand[i]=hand[i][:-1] #print "hand after trailing space removal in filterCrap:",hand #general variable position word filter/string filter From 5c73bd7f3bc312a2ceb3792a078aa85047436c79 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Wed, 15 Oct 2008 18:26:24 +0100 Subject: [PATCH 2/4] p136 - title update - alpha7 --- ...{fpdb-1.0_alpha7_p135.ebuild => fpdb-1.0_alpha7_p136.ebuild} | 2 +- pyfpdb/fpdb.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename packaging/gentoo/{fpdb-1.0_alpha7_p135.ebuild => fpdb-1.0_alpha7_p136.ebuild} (97%) diff --git a/packaging/gentoo/fpdb-1.0_alpha7_p135.ebuild b/packaging/gentoo/fpdb-1.0_alpha7_p136.ebuild similarity index 97% rename from packaging/gentoo/fpdb-1.0_alpha7_p135.ebuild rename to packaging/gentoo/fpdb-1.0_alpha7_p136.ebuild index 07fbb188..58527c79 100644 --- a/packaging/gentoo/fpdb-1.0_alpha7_p135.ebuild +++ b/packaging/gentoo/fpdb-1.0_alpha7_p136.ebuild @@ -1,7 +1,7 @@ # Copyright 1999-2008 Gentoo Foundation # Gentoo had nothing to do with the production of this ebuild, but I'm pre-emptively transferring all copyrights (as far as legally possible under my local jurisdiction) to them. # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/games-util/fpdb/fpdb-1.0_alpha7_p135.ebuild,v 1.0 2008/10/15 steffen@sycamoretest.info Exp $ +# $Header: /var/cvsroot/gentoo-x86/games-util/fpdb/fpdb-1.0_alpha7_p136.ebuild,v 1.0 2008/10/15 steffen@sycamoretest.info Exp $ NEED_PYTHON=2.3 diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index d3642bb5..789fcc30 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -426,7 +426,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) - self.window.set_title("Free Poker DB - version: alpha6+, p135 or higher") + self.window.set_title("Free Poker DB - version: alpha7, p136") self.window.set_border_width(1) self.window.set_size_request(1020,400) self.window.set_resizable(True) From 112f041a981d13fe2183d31563ff229659512a17 Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 16 Oct 2008 21:21:11 +0800 Subject: [PATCH 3/4] Start of changes to parse tournament hostory files --- pyfpdb/fpdb_import.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index b652f204..14c9936d 100755 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -34,6 +34,7 @@ except: import math import os import datetime +import re import fpdb_simple import fpdb_parse_logic from time import time @@ -52,6 +53,7 @@ class Importer: self.updated = 0 #Time last import was run, used as mtime reference self.callHud = False self.lines = None + self.faobs = None #File as one big string self.pos_in_file = {} # dict to remember how far we have read in the file #Set defaults if not self.settings.has_key('imp-callFpdbHud'): @@ -166,6 +168,8 @@ class Importer: if firstline.find("Tournament Summary")!=-1: print "TODO: implement importing tournament summaries" + self.faobs = readfile(inputFile) + self.parseTourneyHistory() return 0 site=fpdb_simple.recogniseSite(firstline) @@ -270,6 +274,12 @@ class Importer: return handsId #end def import_file_dict + def parseTourneyHistory(self): + print "Tourney history parser stub" + #Find tournament boundaries. + #print self.foabs + + def printEmailErrorMessage(self, errors, filename, line): print "Error No.",errors,", please send the hand causing this to steffen@sycamoretest.info so I can fix it." print "Filename:", filename From 5a085a6d236197ff9f066423b1cd95f8d9a71d85 Mon Sep 17 00:00:00 2001 From: Worros Date: Fri, 17 Oct 2008 01:36:02 +0800 Subject: [PATCH 4/4] Draft fix to mtime detection for files --- pyfpdb/GuiAutoImport.py | 2 +- pyfpdb/fpdb_import.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pyfpdb/GuiAutoImport.py b/pyfpdb/GuiAutoImport.py index 6953d1f9..e4d145dd 100644 --- a/pyfpdb/GuiAutoImport.py +++ b/pyfpdb/GuiAutoImport.py @@ -109,7 +109,7 @@ class GuiAutoImport (threading.Thread): self.importer.setQuiet(False) self.importer.setFailOnError(False) self.importer.setHandCount(0) - self.importer.setWatchTime() +# self.importer.setWatchTime() self.server=settings['db-host'] self.user=settings['db-user'] diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 12e854c0..860cb778 100755 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -50,7 +50,7 @@ class Importer: self.filelist = [] self.dirlist = [] self.monitor = False - self.updated = 0 #Time last import was run, used as mtime reference + self.updated = {} #Time last import was run {file:mtime} self.callHud = False self.lines = None self.faobs = None #File as one big string @@ -96,8 +96,8 @@ class Importer: def setFailOnError(self, value): self.settings['failOnError'] = value - def setWatchTime(self): - self.updated = time() +# def setWatchTime(self): +# self.updated = time() def clearFileList(self): self.filelist = [] @@ -142,9 +142,15 @@ class Importer: for file in self.filelist: stat_info = os.stat(file) - if stat_info.st_mtime > self.updated: - self.import_file_dict(file) - self.updated = time() + try: + lastupdate = self.updated[file] +# print "Is " + str(stat_info.st_mtime) + " > " + str(lastupdate) + if stat_info.st_mtime > lastupdate: + self.import_file_dict(file) + self.updated[file] = time() + except: +# print "Adding " + str(file) + " at approx " + str(time()) + self.updated[file] = time() # This is now an internal function that should not be called directly. def import_file_dict(self, file):