[yum-cvs] yum cli.py,1.160,1.161 output.py,1.48,1.49
Menno Smits
mjs at login.linux.duke.edu
Wed Mar 2 22:18:45 UTC 2005
- Previous message: [yum-cvs] yum/yum repos.py, 1.66, 1.67 sqlitecache.py, 1.5, 1.6 sqlitesack.py, 1.9, 1.10
- Next message: [yum-cvs] yum/yum mdcache.py, 1.4, 1.5 repos.py, 1.67, 1.68 sqlitecache.py, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/groups/yum/cvs/yum
In directory login:/tmp/cvs-serv28402
Modified Files:
cli.py output.py
Log Message:
Enhanced callback for reporting cache update progress (no more prints in sqlite code).
Index: cli.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/cli.py,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -r1.160 -r1.161
--- cli.py 2 Mar 2005 07:27:59 -0000 1.160
+++ cli.py 2 Mar 2005 22:18:43 -0000 1.161
@@ -259,7 +259,8 @@
self.repos.callback = None
else:
self.repos.setProgressBar(TextMeter(fo=sys.stdout))
- self.repos.callback = self.simpleProgressBar
+ self.repos.callback = output.CacheProgressCallback(self.log,
+ self.errorlog, self.filelog)
# setup our failure report for failover
freport = (self.failureReport,(),{})
Index: output.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/output.py,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- output.py 2 Mar 2005 12:03:13 -0000 1.48
+++ output.py 2 Mar 2005 22:18:43 -0000 1.49
@@ -46,35 +46,7 @@
def simpleProgressBar(self, current, total, name=None):
- """simple progress bar 50 # marks"""
-
- mark = '#'
- if not sys.stdout.isatty():
- return
-
- if current == 0:
- percent = 0
- else:
- if total != 0:
- percent = current*100/total
- else:
- percent = 0
-
- numblocks = int(percent/2)
- hashbar = mark * numblocks
- if name is None:
- output = '\r%-50s %d/%d' % (hashbar, current, total)
- else:
- output = '\r%-10.10s: %-50s %d/%d' % (name, hashbar, current, total)
-
- if current <= total:
- sys.stdout.write(output)
-
- if current == total:
- sys.stdout.write('\n')
-
- sys.stdout.flush()
-
+ progressbar(current, total, name)
def simpleList(self, pkg):
ver = pkg.printVer()
@@ -509,4 +481,61 @@
def downloadHeader(self, name):
self.log(2, '---> Downloading header for %s to pack into transaction set.' % name)
+
+
+class CacheProgressCallback:
+
+ '''
+ The class handles text output callbacks during metadata cache updates.
+ '''
+
+ def __init__(self, log, errorlog, filelog=None):
+ self.log = log
+ self.errorlog = errorlog
+ self.filelog = filelog
+
+ def log(self, level, message):
+ self.log(level, message)
+
+ def errorlog(self, level, message):
+ if self.errorlog:
+ self.errorlog(level, message)
+
+ def filelog(self, level, message):
+ if self.filelog:
+ self.filelog(level, message)
+
+ def progressbar(self, current, total, name=None):
+ progressbar(current, total, name)
+
+
+def progressbar(current, total, name=None):
+ """simple progress bar 50 # marks"""
+
+ mark = '#'
+ if not sys.stdout.isatty():
+ return
+
+ if current == 0:
+ percent = 0
+ else:
+ if total != 0:
+ percent = current*100/total
+ else:
+ percent = 0
+
+ numblocks = int(percent/2)
+ hashbar = mark * numblocks
+ if name is None:
+ output = '\r%-50s %d/%d' % (hashbar, current, total)
+ else:
+ output = '\r%-10.10s: %-50s %d/%d' % (name, hashbar, current, total)
+
+ if current <= total:
+ sys.stdout.write(output)
+
+ if current == total:
+ sys.stdout.write('\n')
+
+ sys.stdout.flush()
- Previous message: [yum-cvs] yum/yum repos.py, 1.66, 1.67 sqlitecache.py, 1.5, 1.6 sqlitesack.py, 1.9, 1.10
- Next message: [yum-cvs] yum/yum mdcache.py, 1.4, 1.5 repos.py, 1.67, 1.68 sqlitecache.py, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Yum-cvs-commits
mailing list