* show update-repo status, also will be used for package-manager

This commit is contained in:
Faik Uygur
2006-10-10 21:36:32 +00:00
parent 2ecfdc214b
commit 9bd14df287
3 changed files with 22 additions and 2 deletions
+5
View File
@@ -150,6 +150,11 @@ class CLI(UI):
msg = _('Configured %s') % keywords['package'].name msg = _('Configured %s') % keywords['package'].name
elif event == ui.extracting: elif event == ui.extracting:
msg = _('Extracting the files of %s') % keywords['package'].name msg = _('Extracting the files of %s') % keywords['package'].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: else:
msg = None msg = None
if msg: if msg:
+15
View File
@@ -101,15 +101,30 @@ class Index(XmlFile):
self.add_distro(os.path.join(root, fn)) self.add_distro(os.path.join(root, fn))
def update_db(self, repo, txn = None): def update_db(self, repo, txn = None):
# FIXME: updating db takes too much time. So a notify mechanism is used to inform the status
# of the operation.
self.progress = ctx.ui.Progress(len(self.components)+len(self.packages)+len(self.specs))
self.processed = 0
def update_progress():
self.processed += 1
ctx.ui.notify(pisi.ui.progressed, percent = self.progress.update(self.processed),
info = _("Updating package database of %s") % repo)
ctx.ui.notify(pisi.ui.updatingrepo, name = repo)
ctx.componentdb.remove_repo(repo, txn=txn) ctx.componentdb.remove_repo(repo, txn=txn)
for comp in self.components: for comp in self.components:
ctx.componentdb.update_component(comp, repo, txn) ctx.componentdb.update_component(comp, repo, txn)
update_progress()
ctx.packagedb.remove_repo(repo, txn=txn) ctx.packagedb.remove_repo(repo, txn=txn)
for pkg in self.packages: for pkg in self.packages:
ctx.packagedb.add_package(pkg, repo, txn=txn) ctx.packagedb.add_package(pkg, repo, txn=txn)
update_progress()
ctx.sourcedb.remove_repo(repo, txn=txn) ctx.sourcedb.remove_repo(repo, txn=txn)
for sf in self.specs: for sf in self.specs:
ctx.sourcedb.add_spec(sf, repo, txn=txn) ctx.sourcedb.add_spec(sf, repo, txn=txn)
update_progress()
def add_package(self, path, repo_uri): def add_package(self, path, repo_uri):
package = Package(path, 'r') package = Package(path, 'r')
+2 -2
View File
@@ -17,8 +17,8 @@ import sys
import pisi import pisi
import pisi.context as ctx import pisi.context as ctx
(installed, upgraded, removed, installing, removing, (installed, upgraded, removed, installing, removing, configuring, configured, extracting,
configuring, configured, extracting, downloading, packagestogo) = range(10) downloading, packagestogo, updatingrepo, progressed) = range(12)
class UI(object): class UI(object):
"Abstract class for UI operations, derive from this." "Abstract class for UI operations, derive from this."