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

This commit is contained in:
Eratosthenes 2009-11-30 10:30:36 -05:00
commit ef6d46b458
2 changed files with 27 additions and 14 deletions

View File

@ -115,7 +115,7 @@ class fpdb:
self.pages.append(new_page) self.pages.append(new_page)
self.tabs.append(event_box) self.tabs.append(event_box)
self.tab_names.append(new_tab_name) self.tab_names.append(new_tab_name)
#self.nb.append_page(new_page, gtk.Label(new_tab_name)) #self.nb.append_page(new_page, gtk.Label(new_tab_name))
self.nb.append_page(page, event_box) self.nb.append_page(page, event_box)
self.nb_tabs.append(new_tab_name) self.nb_tabs.append(new_tab_name)
@ -135,12 +135,12 @@ class fpdb:
self.nb.set_current_page(tab_no) self.nb.set_current_page(tab_no)
def create_custom_tab(self, text, nb): def create_custom_tab(self, text, nb):
#create a custom tab for notebook containing a #create a custom tab for notebook containing a
#label and a button with STOCK_ICON #label and a button with STOCK_ICON
eventBox = gtk.EventBox() eventBox = gtk.EventBox()
tabBox = gtk.HBox(False, 2) tabBox = gtk.HBox(False, 2)
tabLabel = gtk.Label(text) tabLabel = gtk.Label(text)
tabBox.pack_start(tabLabel, False) tabBox.pack_start(tabLabel, False)
eventBox.add(tabBox) eventBox.add(tabBox)
if nb.get_n_pages() > 0: if nb.get_n_pages() > 0:
@ -157,7 +157,7 @@ class fpdb:
return eventBox return eventBox
def add_icon_to_button(self, button): def add_icon_to_button(self, button):
iconBox = gtk.HBox(False, 0) iconBox = gtk.HBox(False, 0)
image = gtk.Image() image = gtk.Image()
image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_SMALL_TOOLBAR) image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_SMALL_TOOLBAR)
gtk.Button.set_relief(button, gtk.RELIEF_NONE) gtk.Button.set_relief(button, gtk.RELIEF_NONE)
@ -168,8 +168,8 @@ class fpdb:
iconBox.pack_start(image, True, False, 0) iconBox.pack_start(image, True, False, 0)
button.add(iconBox) button.add(iconBox)
iconBox.show() iconBox.show()
return return
# Remove a page from the notebook # Remove a page from the notebook
def remove_tab(self, button, data): def remove_tab(self, button, data):
(nb, text) = data (nb, text) = data
@ -183,7 +183,7 @@ class fpdb:
#print " removing page", page #print " removing page", page
del self.nb_tabs[page] del self.nb_tabs[page]
nb.remove_page(page) nb.remove_page(page)
# Need to refresh the widget -- # Need to refresh the widget --
# This forces the widget to redraw itself. # This forces the widget to redraw itself.
#nb.queue_draw_area(0,0,-1,-1) needed or not?? #nb.queue_draw_area(0,0,-1,-1) needed or not??
@ -752,7 +752,6 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
sys.stderr.write("fpdb starting ...") sys.stderr.write("fpdb starting ...")
def window_state_event_cb(self, window, event): def window_state_event_cb(self, window, event):
print "window_state_event", event
if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED: if event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED:
# -20 = GWL_EXSTYLE can't find it in the pywin32 libs # -20 = GWL_EXSTYLE can't find it in the pywin32 libs
#bits = win32api.GetWindowLong(self.window.window.handle, -20) #bits = win32api.GetWindowLong(self.window.window.handle, -20)

View File

@ -21,7 +21,7 @@
import os # todo: remove this once import_dir is in fpdb_import import os # todo: remove this once import_dir is in fpdb_import
import sys import sys
from time import time, strftime, sleep from time import time, strftime, sleep, clock
import traceback import traceback
import math import math
import datetime import datetime
@ -101,6 +101,8 @@ class Importer:
self.NEWIMPORT = Configuration.NEWIMPORT self.NEWIMPORT = Configuration.NEWIMPORT
clock() # init clock in windows
#Set functions #Set functions
def setCallHud(self, value): def setCallHud(self, value):
self.callHud = 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] # print "file",counter," updated", os.path.basename(file), stat_info.st_size, self.updatedsize[file], stat_info.st_mtime, self.updatedtime[file]
try: try:
if not os.path.isdir(file): 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? except KeyError: # TODO: What error happens here?
pass 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.updatedsize[file] = stat_info.st_size
self.updatedtime[file] = time() self.updatedtime[file] = time()
else: else:
@ -393,7 +400,7 @@ class Importer:
if os.path.isdir(file): if os.path.isdir(file):
self.addToDirList[file] = [site] + [filter] self.addToDirList[file] = [site] + [filter]
return return (0,0,0,0,0)
conv = None conv = None
(stored, duplicates, partial, errors, ttime) = (0, 0, 0, 0, 0) (stored, duplicates, partial, errors, ttime) = (0, 0, 0, 0, 0)
@ -472,10 +479,13 @@ class Importer:
self.pos_in_file[file] = inputFile.tell() self.pos_in_file[file] = inputFile.tell()
inputFile.close() inputFile.close()
x = clock()
(stored, duplicates, partial, errors, ttime, handsId) = self.import_fpdb_lines(db, self.lines, starttime, file, site, q) (stored, duplicates, partial, errors, ttime, handsId) = self.import_fpdb_lines(db, self.lines, starttime, file, site, q)
db.commit() db.commit()
ttime = time() - starttime y = clock()
ttime = y - x
#ttime = time() - starttime
if q is None: if q is None:
log.info("Total stored: %(stored)d\tduplicates:%(duplicates)d\terrors:%(errors)d\ttime:%(ttime)s" % locals()) log.info("Total stored: %(stored)d\tduplicates:%(duplicates)d\terrors:%(errors)d\ttime:%(ttime)s" % locals())
@ -554,7 +564,11 @@ class Importer:
#print "call to HUD here. handsId:",handsId #print "call to HUD here. handsId:",handsId
#pipe the Hands.id out to the HUD #pipe the Hands.id out to the HUD
# print "fpdb_import: sending hand to hud", handsId, "pipe =", self.caller.pipe_to_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: except Exceptions.DuplicateError:
duplicates += 1 duplicates += 1
db.rollback() db.rollback()