* show update-repo status, also will be used for package-manager
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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')
|
||||
|
||||
+2
-2
@@ -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."
|
||||
|
||||
Reference in New Issue
Block a user