Show progress while taking snapshot

This commit is contained in:
Faik Uygur
2008-06-16 07:48:34 +00:00
parent dfc8db87c2
commit a7a4fe57cf
2 changed files with 20 additions and 2 deletions
+11 -2
View File
@@ -353,11 +353,15 @@ def snapshot():
installed. The record is kept by pisi history mechanism as it works automatically on install, remove installed. The record is kept by pisi history mechanism as it works automatically on install, remove
and upgrade operations. and upgrade operations.
""" """
installdb = pisi.db.installdb.InstallDB() installdb = pisi.db.installdb.InstallDB()
historydb = pisi.db.historydb.HistoryDB() historydb = pisi.db.historydb.HistoryDB()
historydb.create_history("snapshot") historydb.create_history("snapshot")
li = installdb.list_installed()
progress = ctx.ui.Progress(len(li))
processed = 0
for name in installdb.list_installed(): for name in installdb.list_installed():
package = installdb.get_package(name) package = installdb.get_package(name)
historydb.add_package(pkgBefore=package, operation="snapshot") historydb.add_package(pkgBefore=package, operation="snapshot")
@@ -366,6 +370,11 @@ def snapshot():
if f.type == "config" and pisi.util.config_changed(f): if f.type == "config" and pisi.util.config_changed(f):
historydb.save_config(name, "/%s" % f.path) historydb.save_config(name, "/%s" % f.path)
processed += 1
ctx.ui.display_progress(operation = "snapshot",
percent = progress.update(processed),
info = _("Taking snapshot of the system"))
historydb.update_history() historydb.update_history()
# ****** Danger Zone Below! Tressspassers' eyes will explode! ********** # # ****** Danger Zone Below! Tressspassers' eyes will explode! ********** #
+9
View File
@@ -26,6 +26,15 @@ class UI(object):
except ArithmeticError: except ArithmeticError:
self.percent = 0 self.percent = 0
def update(self, size):
if not self.totalsize:
return 100
try:
self.percent = (size * 100) / self.totalsize
except ArithmeticError:
self.percent = 0
return self.percent
def __init__(self, debuggy = False, verbose = False): def __init__(self, debuggy = False, verbose = False):
self.show_debug = debuggy self.show_debug = debuggy
self.show_verbose = verbose self.show_verbose = verbose