From 6df03cb2343ec2abc1932c855c84e2441afb016c Mon Sep 17 00:00:00 2001 From: eblade Date: Fri, 31 Jul 2009 01:15:28 -0400 Subject: [PATCH] HUD_main: if new hand id int is not available, we can't print it, so that generates a second error, double fault fpdb_import: ok, we're keeping two lists now, one with updated st_size and one with m_time. grrr. --- pyfpdb/HUD_main.py | 3 ++- pyfpdb/fpdb_import.py | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pyfpdb/HUD_main.py b/pyfpdb/HUD_main.py index 218707bd..7378d6f7 100755 --- a/pyfpdb/HUD_main.py +++ b/pyfpdb/HUD_main.py @@ -163,7 +163,8 @@ class HUD_main(object): cards['common'] = comm_cards['common'] except Exception, err: print "db error: skipping ", new_hand_id, err - sys.stderr.write("Database error %s in hand %d. Skipping.\n" % (err, int(new_hand_id))) + if new_hand_id: # new_hand_id is none if we had an error prior to the store + sys.stderr.write("Database error %s in hand %d. Skipping.\n" % (err, int(new_hand_id))) continue if type == "tour": # hand is from a tournament diff --git a/pyfpdb/fpdb_import.py b/pyfpdb/fpdb_import.py index 76b483ba..85526d2c 100644 --- a/pyfpdb/fpdb_import.py +++ b/pyfpdb/fpdb_import.py @@ -68,7 +68,8 @@ class Importer: self.addToDirList = {} self.removeFromFileList = {} # to remove deleted files self.monitor = False - self.updated = {} #Time last import was run {file:mtime} + self.updatedsize = {} + self.updatedtime = {} 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 @@ -268,15 +269,18 @@ class Importer: if os.path.exists(file): stat_info = os.stat(file) #rulog.writelines("path exists ") - if file in self.updated: - if stat_info.st_size > self.updated[file]: + if file in self.updatedsize: # we should be able to assume that if we're in size, we're in time as well + if stat_info.st_size > self.updatedsize[file] or stat_info.st_mtime > self.updatedtime[file]: self.import_file_dict(file, self.filelist[file][0], self.filelist[file][1]) - self.updated[file] = stat_info.st_size + self.updatedsize[file] = stat_info.st_size + self.updatedtime[file] = time() else: if os.path.isdir(file) or (time() - stat_info.st_mtime) < 60: - self.updated[file] = 0 + self.updatedsize[file] = 0 + self.updatedtime[file] = 0 else: - self.updated[file] = stat_info.st_size + self.updatedsize[file] = stat_info.st_size + self.updatedtime[file] = time() else: self.removeFromFileList[file] = True self.addToDirList = filter(lambda x: self.addImportDirectory(x, True, self.addToDirList[x][0], self.addToDirList[x][1]), self.addToDirList)