Merge branch 'master' of git://git.assembla.com/fpdb-eric

This commit is contained in:
Worros
2009-12-07 12:10:56 +08:00
7 changed files with 347 additions and 335 deletions
+20 -6
View File
@@ -21,7 +21,7 @@
import os # todo: remove this once import_dir is in fpdb_import
import sys
from time import time, strftime, sleep
from time import time, strftime, sleep, clock
import traceback
import math
import datetime
@@ -101,6 +101,8 @@ class Importer:
self.NEWIMPORT = Configuration.NEWIMPORT
clock() # init clock in windows
#Set functions
def setCallHud(self, value):
self.callHud = value
@@ -359,10 +361,15 @@ class Importer:
# print "file",counter," updated", os.path.basename(file), stat_info.st_size, self.updatedsize[file], stat_info.st_mtime, self.updatedtime[file]
try:
if not os.path.isdir(file):
self.caller.addText("\n"+file)
self.caller.addText("\n"+os.path.basename(file))
except KeyError: # TODO: What error happens here?
pass
self.import_file_dict(self.database, file, self.filelist[file][0], self.filelist[file][1], None)
(stored, duplicates, partial, errors, ttime) = self.import_file_dict(self.database, file, self.filelist[file][0], self.filelist[file][1], None)
try:
if not os.path.isdir(file):
self.caller.addText(" %d stored, %d duplicates, %d partial, %d errors (time = %f)" % (stored, duplicates, partial, errors, ttime))
except KeyError: # TODO: Again, what error happens here? fix when we find out ..
pass
self.updatedsize[file] = stat_info.st_size
self.updatedtime[file] = time()
else:
@@ -393,7 +400,7 @@ class Importer:
if os.path.isdir(file):
self.addToDirList[file] = [site] + [filter]
return
return (0,0,0,0,0)
conv = None
(stored, duplicates, partial, errors, ttime) = (0, 0, 0, 0, 0)
@@ -481,10 +488,13 @@ class Importer:
self.pos_in_file[file] = inputFile.tell()
inputFile.close()
x = clock()
(stored, duplicates, partial, errors, ttime, handsId) = self.import_fpdb_lines(db, self.lines, starttime, file, site, q)
db.commit()
ttime = time() - starttime
y = clock()
ttime = y - x
#ttime = time() - starttime
if q is None:
log.info("Total stored: %(stored)d\tduplicates:%(duplicates)d\terrors:%(errors)d\ttime:%(ttime)s" % locals())
@@ -563,7 +573,11 @@ class Importer:
#print "call to HUD here. handsId:",handsId
#pipe the Hands.id out to the HUD
# print "fpdb_import: sending hand to hud", handsId, "pipe =", self.caller.pipe_to_hud
self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep)
try:
self.caller.pipe_to_hud.stdin.write("%s" % (handsId) + os.linesep)
except IOError: # hud closed
self.callHud = False
pass # continue import without hud
except Exceptions.DuplicateError:
duplicates += 1
db.rollback()