[yum-cvs] 2 commits - cli.py output.py yum/sqlitesack.py
Seth Vidal
skvidal at linux.duke.edu
Mon Aug 13 21:45:52 UTC 2007
cli.py | 14 ++++--------
output.py | 62 ++++++++++++++++++++++++++++++++++--------------------
yum/sqlitesack.py | 1
3 files changed, 46 insertions(+), 31 deletions(-)
New commits:
commit 813bc0396912b8ba6b10df8f999c1a016f2417be
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Mon Aug 13 17:43:13 2007 -0400
hook up yum-cli to the new transaction callback
add YumCliCallback to output.py
diff --git a/cli.py b/cli.py
index 7ccfad7..683fb15 100644
--- a/cli.py
+++ b/cli.py
@@ -36,7 +36,7 @@ import rpmUtils.arch
import rpmUtils.miscutils
from yum.packages import parsePackages, YumLocalPackage
from i18n import _
-import callback
+from yum.rpmtrans import RPMTransaction
import signal
import yumcommands
@@ -340,8 +340,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
for feature in ['diskspacecheck']: # more to come, I'm sure
tsConf[feature] = getattr(self.conf, feature)
- testcb = callback.RPMInstallCallback(output=0)
- testcb.tsInfo = self.tsInfo
+ testcb = RPMTransaction(self.tsInfo)
self.initActionTs()
# save our dsCallback out
@@ -374,13 +373,10 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
# put back our depcheck callback
self.dsCallback = dscb
-
- output = 1
+ # setup our rpm ts callback
+ cb = RPMTransaction(self.tsInfo, display=output.YumCliRPMCallBack)
if self.conf.debuglevel < 2:
- output = 0
- cb = callback.RPMInstallCallback(output=output)
- cb.filelog = True
- cb.tsInfo = self.tsInfo
+ cb.display.output = False
self.verbose_logger.log(yum.logginglevels.INFO_2, 'Running Transaction')
self.runTransaction(cb=cb)
diff --git a/output.py b/output.py
index 664f6c3..073cb0c 100644
--- a/output.py
+++ b/output.py
@@ -20,12 +20,14 @@
import sys
import time
import logging
+import types
from i18n import _
from urlgrabber.progress import TextMeter
from urlgrabber.grabber import URLGrabError
from yum.misc import sortPkgObj, prco_tuple_to_string
from rpmUtils.miscutils import checkSignals
+from yum.constants import *
from yum import logginglevels
@@ -462,6 +464,7 @@ class YumCliRPMCallBack:
TS_OBSOLETING: 'Installing',
TS_UPDATED: 'Cleanup',
'repackaging': 'Repackaging'}
+
self.fileaction = { TS_UPDATE: 'Updated',
TS_ERASE: 'Erased',
TS_INSTALL: 'Installed',
@@ -472,6 +475,7 @@ class YumCliRPMCallBack:
self.lastmsg = None
self.logger = logging.getLogger('yum.filelogging.RPMInstallCallback')
self.lastpackage = None # name of last package we looked at
+ self.output = True
# for a progress bar
self.mark = "#"
@@ -480,13 +484,28 @@ class YumCliRPMCallBack:
def event(self, package, action, te_current, te_total, ts_current, ts_total):
# this is where a progress bar would be called
- msg = '%s: %s %s/%s [%s/%s]' % (self.action[action], package,
- te_current, te_total, ts_current, ts_total)
- if msg != self.lastmsg:
- print msg
- self.lastmsg = msg
+ process = self.action[action]
+
+ if type(package) not in types.StringTypes:
+ pkgname = package.name
+ else:
+ pkgname = package
+
self.lastpackage = package
- #if sys.stdout.isatty(): # need this for the nice progress bar output
+ if te_total == 0:
+ percent = 0
+ else:
+ percent = (te_current*100L)/te_total
+
+ if self.output and (sys.stdout.isatty() or bytes == total):
+ fmt = self._makefmt(percent, ts_current, ts_total)
+ msg = fmt % (process, pkgname)
+ if msg != self.lastmsg:
+ sys.stdout.write(msg)
+ sys.stdout.flush()
+ self.lastmsg = msg
+ if te_current == te_total:
+ print " "
def errorlog(self, msg):
print >> sys.stderr, msg
@@ -496,22 +515,21 @@ class YumCliRPMCallBack:
msg = '%s: %s' % (self.fileaction[action], package)
self.logger.info(msg)
- #def _makefmt(self, percent, progress = True):
- #l = len(str(self.total_actions))
- #size = "%s.%s" % (l, l)
- #fmt_done = "[%" + size + "s/%" + size + "s]"
- #done = fmt_done % (self.total_installed + self.total_removed,
- #self.total_actions)
- #marks = self.marks - (2 * l)
- #width = "%s.%s" % (marks, marks)
- #fmt_bar = "%-" + width + "s"
- #if progress:
- #bar = fmt_bar % (self.mark * int(marks * (percent / 100.0)), )
- #fmt = "\r %-10.10s: %-28.28s " + bar + " " + done
- #else:
- #bar = fmt_bar % (self.mark * marks, )
- #fmt = " %-10.10s: %-28.28s " + bar + " " + done
- #return fmt
+ def _makefmt(self, percent, ts_current, ts_total, progress = True):
+ l = len(str(ts_total))
+ size = "%s.%s" % (l, l)
+ fmt_done = "[%" + size + "s/%" + size + "s]"
+ done = fmt_done % (ts_current, ts_total)
+ marks = self.marks - (2 * l)
+ width = "%s.%s" % (marks, marks)
+ fmt_bar = "%-" + width + "s"
+ if progress:
+ bar = fmt_bar % (self.mark * int(marks * (percent / 100.0)), )
+ fmt = "\r %-10.10s: %-28.28s " + bar + " " + done
+ else:
+ bar = fmt_bar % (self.mark * marks, )
+ fmt = " %-10.10s: %-28.28s " + bar + " " + done
+ return fmt
def progressbar(current, total, name=None):
commit fee78c9fd85d73884cd3b8cd214a0f4bc4256a2e
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Mon Aug 13 09:39:28 2007 -0400
remove double trailing slashes as they are just crap.
closes rh bug #246485
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 86040c2..9330876 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -806,6 +806,7 @@ def encodefilenamelist(filenamelist):
# Return a list representing filestring (filenames can not contain /)
def decodefilenamelist(filenamestring):
+ filenamestring = filenamestring.replace('//', '/')
return filenamestring.split('/')
# Return a string representing filetypeslist
More information about the Yum-cvs-commits
mailing list