Show progress while taking snapshot
This commit is contained in:
@@ -358,6 +358,10 @@ def snapshot():
|
|||||||
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! ********** #
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user