From da602b29084eec0f1ea4aa0fe8eb3f3245fedc28 Mon Sep 17 00:00:00 2001 From: Matt Turnbull Date: Thu, 26 Feb 2009 15:36:23 +0000 Subject: [PATCH] temp --- pyfpdb/HandHistoryConverter.py | 2 +- pyfpdb/fpdb_import.py | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/pyfpdb/HandHistoryConverter.py b/pyfpdb/HandHistoryConverter.py index 2c547a42..82e523ac 100644 --- a/pyfpdb/HandHistoryConverter.py +++ b/pyfpdb/HandHistoryConverter.py @@ -365,7 +365,7 @@ class HandHistoryConverter(threading.Thread): if(self.filetype == "text"): if self.in_path == '-': # read from stdin - logging.debug("Reading stdin with %s" % self.codepage) + logging.debug("Reading stdin with %s" % self.codepage) # is this necessary? or possible? or what? in_fh = codecs.getreader('cp1252')(sys.stdin) else: logging.debug("Opening %s with %s" % (self.in_path, self.codepage)) diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 2a339663..51f86b77 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -181,9 +181,10 @@ class Importer: #Run import on updated files, then store latest update time. def runUpdated(self): - #Check for new files in directory + #Check for new files in monitored directories #todo: make efficient - always checks for new file, should be able to use mtime of directory # ^^ May not work on windows + for site in self.dirlist: self.addImportDirectory(self.dirlist[site][0], False, site, self.dirlist[site][1]) @@ -196,10 +197,15 @@ class Importer: self.updated[file] = time() except: self.updated[file] = time() - # This codepath only runs first time the file is found, if modified in the last - # minute run an immediate import. - if (time() - stat_info.st_mtime) < 60 or os.path.isdir(file): # TODO: figure out a way to dispatch this to the seperate thread so our main window doesn't lock up on initial import + # If modified in the last minute run an immediate import. + # This codepath only runs first time the file is found. + if (time() - stat_info.st_mtime) < 60: + # TODO attach a HHC thread to the file + # TODO import the output of the HHC thread -- this needs to wait for the HHC to block? self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1]) + # TODO we also test if directory, why? + #if os.path.isdir(file): + #self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1]) for dir in self.addToDirList: self.addImportDirectory(dir, True, self.addToDirList[dir][0], self.addToDirList[dir][1]) @@ -221,10 +227,19 @@ class Importer: # someone can just create their own python module for it if filter == "EverleafToFpdb": print "converting ", file - conv = EverleafToFpdb.Everleaf(self.config, file) + hhbase = self.config.get_import_parameters().get("hhArchiveBase") + hhbase = os.path.expanduser(hhbase) + hhdir = os.path.join(hhbase,site) + try: + ofile = os.path.join(hhdir, file.split(os.path.sep)[-2]+"-"+os.path.basename(file)) + except: + ofile = os.path.join(hhdir, "x"+strftime("%d-%m-%y")+os.path.basename(file)) + out_fh = open(ofile, 'w') # TODO: seek to previous place in input and append output + in_fh = + conv = EverleafToFpdb.Everleaf(in_fh = file, out_fh = out_fh) elif filter == "FulltiltToFpdb": print "converting ", file - conv = FulltiltToFpdb.FullTilt(self.config, file) + conv = FulltiltToFpdb.FullTilt(in_fh = file, out_fh = out_fh) else: print "Unknown filter ", filter return