From 9bd14df2877bc2fd413e685d8b94565aea561d2c Mon Sep 17 00:00:00 2001 From: Faik Uygur Date: Tue, 10 Oct 2006 21:36:32 +0000 Subject: [PATCH] * show update-repo status, also will be used for package-manager --- pisi/cli/__init__.py | 5 +++++ pisi/index.py | 15 +++++++++++++++ pisi/ui.py | 4 ++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pisi/cli/__init__.py b/pisi/cli/__init__.py index b2b3ab88..39f1705a 100644 --- a/pisi/cli/__init__.py +++ b/pisi/cli/__init__.py @@ -150,6 +150,11 @@ class CLI(UI): msg = _('Configured %s') % keywords['package'].name elif event == ui.extracting: 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: msg = None if msg: diff --git a/pisi/index.py b/pisi/index.py index 1e24d2da..9c14e76e 100644 --- a/pisi/index.py +++ b/pisi/index.py @@ -101,15 +101,30 @@ class Index(XmlFile): self.add_distro(os.path.join(root, fn)) 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) for comp in self.components: ctx.componentdb.update_component(comp, repo, txn) + update_progress() ctx.packagedb.remove_repo(repo, txn=txn) for pkg in self.packages: ctx.packagedb.add_package(pkg, repo, txn=txn) + update_progress() ctx.sourcedb.remove_repo(repo, txn=txn) for sf in self.specs: ctx.sourcedb.add_spec(sf, repo, txn=txn) + update_progress() def add_package(self, path, repo_uri): package = Package(path, 'r') diff --git a/pisi/ui.py b/pisi/ui.py index 01d45686..08d1dbf5 100644 --- a/pisi/ui.py +++ b/pisi/ui.py @@ -17,8 +17,8 @@ import sys import pisi import pisi.context as ctx -(installed, upgraded, removed, installing, removing, - configuring, configured, extracting, downloading, packagestogo) = range(10) +(installed, upgraded, removed, installing, removing, configuring, configured, extracting, + downloading, packagestogo, updatingrepo, progressed) = range(12) class UI(object): "Abstract class for UI operations, derive from this."