* unified progress

* do not show progress info while removing package in cli
This commit is contained in:
Faik Uygur
2006-10-18 07:53:16 +00:00
parent b83bea9d78
commit 4b50973688
5 changed files with 25 additions and 23 deletions
+3 -4
View File
@@ -423,10 +423,9 @@ class Remove(AtomicOperation):
for fileinfo in self.files.list:
self.remove_file(fileinfo)
removed += 1
ctx.ui.notify(pisi.ui.progressed,
operation = "removing",
percent = progress.update(removed),
info = _("Removing package %s") % self.package_name)
ctx.ui.display_progress(operation = "removing",
percent = progress.update(removed),
info = _("Removing package %s") % self.package_name)
txn = ctx.dbenv.txn_begin()
try:
+16 -13
View File
@@ -123,14 +123,22 @@ class CLI(UI):
return True
return False
def display_progress(self, **ka):
totalsize = '%.1f %s' % pisi.util.human_readable_size(ka['total_size'])
out = '\r%-30.30s (%s)%3d%% %9.2f %s [%s]' % \
(ka['filename'], totalsize, ka['percent'],
ka['rate'], ka['symbol'], ka['eta'])
self.output(out)
if ka['percent'] == 100:
def display_progress(self, operation, percent, info="", **ka):
""" display progress of any operation """
if operation == "removing":
return
elif operation == "fetching":
totalsize = '%.1f %s' % pisi.util.human_readable_size(ka['total_size'])
out = '\r%-30.30s (%s)%3d%% %9.2f %s [%s]' % \
(ka['filename'], totalsize, percent,
ka['rate'], ka['symbol'], ka['eta'])
self.output(out)
else:
self.output("\r%s (%d%%)" % (keywords['info'], percent))
if percent == 100:
self.output(colorize(_(' [complete]\n'), 'gray'))
def status(self, msg = None):
@@ -150,11 +158,6 @@ class CLI(UI):
msg = _('Configured %s') % keywords['package'].name
elif event == ui.extracting:
msg = _('Extracting the files of %s') % keywords['name']
if event == ui.progressed:
self.output("\r%s (%d%%)" % (keywords['info'], keywords['percent']))
if keywords['percent'] == 100:
self.output(colorize(_(' [complete]\n'), 'gray'))
msg = None
else:
msg = None
if msg:
+2 -1
View File
@@ -138,8 +138,9 @@ class Fetcher:
if p.update(downloaded_size):
self.percent = p.percent
if not self.complete:
ctx.ui.display_progress(filename = self.url.filename(),
ctx.ui.display_progress(operation = "fetching",
percent = self.percent,
filename = self.url.filename(),
total_size = total_size,
downloaded_size = downloaded_size,
rate = self.rate,
+3 -4
View File
@@ -108,10 +108,9 @@ class Index(XmlFile):
def update_progress():
self.processed += 1
ctx.ui.notify(pisi.ui.progressed,
operation = "updatingrepo",
percent = self.progress.update(self.processed),
info = _("Updating package database of %s") % repo)
ctx.ui.display_progress(operation = "updatingrepo",
percent = self.progress.update(self.processed),
info = _("Updating package database of %s") % repo)
ctx.componentdb.remove_repo(repo, txn=txn)
for comp in self.components:
+1 -1
View File
@@ -18,7 +18,7 @@ import pisi
import pisi.context as ctx
(installed, upgraded, removed, installing, removing, configuring, configured, extracting,
downloading, packagestogo, updatingrepo, progressed) = range(12)
downloading, packagestogo, updatingrepo) = range(11)
class UI(object):
"Abstract class for UI operations, derive from this."