Merge branch 'master' of git://git.assembla.com/fpdb-gimick
This commit is contained in:
commit
6ce19d70dc
|
@ -142,10 +142,12 @@ class GuiBulkImport():
|
|||
"""returns the vbox of this thread"""
|
||||
return self.vbox
|
||||
|
||||
def __init__(self, settings, config, sql = None):
|
||||
def __init__(self, settings, config, parent, sql = None):
|
||||
self.settings = settings
|
||||
self.config = config
|
||||
self.importer = fpdb_import.Importer(self, self.settings, config, sql)
|
||||
self.parent = parent
|
||||
|
||||
self.importer = fpdb_import.Importer(self, self.settings, config,parent, sql)
|
||||
|
||||
self.vbox = gtk.VBox(False, 0)
|
||||
self.vbox.show()
|
||||
|
@ -385,7 +387,7 @@ def main(argv=None):
|
|||
print _('-q is deprecated. Just use "-f filename" instead')
|
||||
# This is because -q on its own causes an error, so -f is necessary and sufficient for cmd line use
|
||||
if not options.filename:
|
||||
i = GuiBulkImport(settings, config)
|
||||
i = GuiBulkImport(settings, config, None)
|
||||
main_window = gtk.Window()
|
||||
main_window.connect('destroy', destroy)
|
||||
main_window.add(i.vbox)
|
||||
|
@ -393,7 +395,7 @@ def main(argv=None):
|
|||
gtk.main()
|
||||
else:
|
||||
#Do something useful
|
||||
importer = fpdb_import.Importer(False,settings, config)
|
||||
importer = fpdb_import.Importer(False,settings, config, self.parent)
|
||||
# importer.setDropIndexes("auto")
|
||||
importer.setDropIndexes(_("don't drop"))
|
||||
importer.setFailOnError(options.failOnError)
|
||||
|
|
|
@ -999,7 +999,7 @@ class fpdb:
|
|||
|
||||
def tab_bulk_import(self, widget, data=None):
|
||||
"""opens a tab for bulk importing"""
|
||||
new_import_thread = GuiBulkImport.GuiBulkImport(self.settings, self.config, self.sql)
|
||||
new_import_thread = GuiBulkImport.GuiBulkImport(self.settings, self.config, self.window, self.sql)
|
||||
self.threads.append(new_import_thread)
|
||||
bulk_tab=new_import_thread.get_vbox()
|
||||
self.add_and_display_tab(bulk_tab, _("Bulk Import"))
|
||||
|
|
|
@ -70,12 +70,13 @@ else:
|
|||
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
|
||||
|
||||
class Importer:
|
||||
def __init__(self, caller, settings, config, sql = None):
|
||||
def __init__(self, caller, settings, config, parent, sql = None):
|
||||
"""Constructor"""
|
||||
self.settings = settings
|
||||
self.caller = caller
|
||||
self.config = config
|
||||
self.sql = sql
|
||||
self.parent = parent
|
||||
|
||||
#log = Configuration.get_logger("logging.conf", "importer", log_dir=self.config.dir_log)
|
||||
self.filelist = {}
|
||||
|
@ -301,7 +302,16 @@ class Importer:
|
|||
totpartial = 0
|
||||
toterrors = 0
|
||||
tottime = 0
|
||||
progresscount = 0
|
||||
progressgoal = len(self.filelist)
|
||||
|
||||
ProgressDialog = ProgressBar(self.parent)
|
||||
|
||||
for file in self.filelist:
|
||||
|
||||
progresscount += 1
|
||||
ProgressDialog.progress_update(progresscount,progressgoal)
|
||||
|
||||
(stored, duplicates, partial, errors, ttime) = self.import_file_dict(db, file
|
||||
,self.filelist[file][0], self.filelist[file][1], q)
|
||||
totstored += stored
|
||||
|
@ -313,6 +323,8 @@ class Importer:
|
|||
print _("sending finish message queue length ="), q.qsize()
|
||||
db.send_finish_msg(q)
|
||||
|
||||
del ProgressDialog
|
||||
|
||||
return (totstored, totdups, totpartial, toterrors)
|
||||
# end def importFiles
|
||||
|
||||
|
@ -527,6 +539,44 @@ class Importer:
|
|||
logfile.write(str(s) + "\n")
|
||||
logfile.write("\n")
|
||||
logfile.close()
|
||||
|
||||
|
||||
class ProgressBar:
|
||||
|
||||
def __del__(self):
|
||||
self.progress.destroy()
|
||||
|
||||
def progress_update(self, fraction, sum):
|
||||
|
||||
progresspercent = float(fraction) / (float(sum) + 1.0)
|
||||
|
||||
self.pbar.set_fraction(progresspercent)
|
||||
self.pbar.set_text(str(fraction) + " / " + str(sum))
|
||||
|
||||
def __init__(self, parent):
|
||||
|
||||
self.progress = gtk.Window(gtk.WINDOW_TOPLEVEL)
|
||||
|
||||
self.progress.set_resizable(False)
|
||||
self.progress.set_modal(True)
|
||||
self.progress.set_transient_for(parent)
|
||||
self.progress.set_decorated(False)
|
||||
|
||||
vbox = gtk.VBox(False, 5)
|
||||
vbox.set_border_width(10)
|
||||
self.progress.add(vbox)
|
||||
vbox.show()
|
||||
|
||||
align = gtk.Alignment(0.5, 0.5, 0, 0)
|
||||
vbox.pack_start(align, True, True, 2)
|
||||
align.show()
|
||||
|
||||
self.pbar = gtk.ProgressBar()
|
||||
align.add(self.pbar)
|
||||
self.pbar.show()
|
||||
|
||||
self.progress.show()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print _("CLI for fpdb_import is now available as CliFpdb.py")
|
||||
|
|
Loading…
Reference in New Issue
Block a user