[yum-commits] Branch 'yum-3_2_X' - 2 commits - output.py yum/update_md.py
James Antill
james at osuosl.org
Fri Feb 4 18:56:49 UTC 2011
output.py | 43 ++++++++++++++++++++++++++++++++++---------
yum/update_md.py | 11 ++++++++++-
2 files changed, 44 insertions(+), 10 deletions(-)
New commits:
commit 2a5d185b921f028b0216edec42beb41efef97061
Author: James Antill <james at and.org>
Date: Fri Feb 4 11:24:41 2011 -0500
Hide invalid XML errors for updateinfo, BZ 663378
diff --git a/yum/update_md.py b/yum/update_md.py
index 83e56c6..619250e 100644
--- a/yum/update_md.py
+++ b/yum/update_md.py
@@ -32,6 +32,15 @@ import Errors
import rpmUtils.miscutils
+
+def safe_iterparse(filename):
+ """ Works like iterparse, but hides XML errors (prints a warning). """
+ try:
+ for event, elem in safe_iterparse(infile):
+ yield event, elem
+ except SyntaxError: # Bad XML
+ print >> sys.stderr, "File is not valid XML:", filename
+
class UpdateNoticeException(Exception):
""" An exception thrown for bad UpdateNotice data. """
pass
@@ -445,7 +454,7 @@ class UpdateMetadata(object):
else: # obj is a file object
infile = obj
- for event, elem in iterparse(infile):
+ for event, elem in safe_iterparse(infile):
if elem.tag == 'update':
try:
un = UpdateNotice(elem)
commit d2c806ae70be38881f3a1000fd5bd7354a8fed0e
Author: James Antill <james at and.org>
Date: Sat Jan 29 17:31:30 2011 -0500
Show from_repo in history output, if available.
diff --git a/output.py b/output.py
index 04b718b..08fe0e3 100755
--- a/output.py
+++ b/output.py
@@ -1619,6 +1619,18 @@ to exit.
self._historyInfoCmd(mobj)
+ def _hpkg2from_repo(self, hpkg):
+ """ Given a pkg, find the ipkg.ui_from_repo ... if none, then
+ get an apkg. ... and put a ? in there. """
+ ipkgs = self.rpmdb.searchPkgTuple(hpkg.pkgtup)
+ if not ipkgs:
+ apkgs = self.pkgSack.searchPkgTuple(hpkg.pkgtup)
+ if not apkgs:
+ return '?'
+ return '@?' + str(apkgs[0].repoid)
+
+ return ipkgs[0].ui_from_repo
+
def _historyInfoCmd(self, old, pats=[]):
name = self._pwd_ui_username(old.loginuid)
@@ -1631,7 +1643,8 @@ to exit.
_pkg_states_available.values())])[-1]
_pkg_states_installed['maxlen'] = maxlen
_pkg_states_available['maxlen'] = maxlen
- def _simple_pkg(pkg, prefix_len, was_installed=False, highlight=False):
+ def _simple_pkg(pkg, prefix_len, was_installed=False, highlight=False,
+ pkg_max_len=0):
prefix = " " * prefix_len
if was_installed:
_pkg_states = _pkg_states_installed
@@ -1655,7 +1668,9 @@ to exit.
else:
(hibeg, hiend) = self._highlight('normal')
state = utf8_width_fill(state, _pkg_states['maxlen'])
- print "%s%s%s%s %s" % (prefix, hibeg, state, hiend, hpkg)
+ print "%s%s%s%s %-*s %s" % (prefix, hibeg, state, hiend,
+ pkg_max_len, hpkg,
+ self._hpkg2from_repo(hpkg))
if type(old.tid) == type([]):
print _("Transaction ID :"), "%u..%u" % (old.tid[0], old.tid[-1])
@@ -1732,24 +1747,31 @@ to exit.
print _("Additional non-default information stored: %d"
% len(non_default))
- print _("Transaction performed with:")
+ if old.trans_with:
+ # This is _possible_, but not common
+ print _("Transaction performed with:")
+ pkg_max_len = max((len(str(hpkg)) for hpkg in old.trans_with))
for hpkg in old.trans_with:
- _simple_pkg(hpkg, 4, was_installed=True)
+ _simple_pkg(hpkg, 4, was_installed=True, pkg_max_len=pkg_max_len)
print _("Packages Altered:")
self.historyInfoCmdPkgsAltered(old, pats)
if old.trans_skip:
print _("Packages Skipped:")
+ pkg_max_len = max((len(str(hpkg)) for hpkg in old.trans_skip))
for hpkg in old.trans_skip:
- _simple_pkg(hpkg, 4)
+ _simple_pkg(hpkg, 4, pkg_max_len=pkg_max_len)
if old.rpmdb_problems:
print _("Rpmdb Problems:")
for prob in old.rpmdb_problems:
key = "%s%s: " % (" " * 4, prob.problem)
print self.fmtKeyValFill(key, prob.text)
+ if prob.packages:
+ pkg_max_len = max((len(str(hpkg)) for hpkg in prob.packages))
for hpkg in prob.packages:
- _simple_pkg(hpkg, 8, was_installed=True, highlight=hpkg.main)
+ _simple_pkg(hpkg, 8, was_installed=True, highlight=hpkg.main,
+ pkg_max_len=pkg_max_len)
if old.output:
print _("Scriptlet output:")
@@ -1783,10 +1805,13 @@ to exit.
# version in the transaction and now.
all_uistates = self._history_state2uistate
maxlen = 0
+ pkg_max_len = 0
for hpkg in old.trans_data:
uistate = all_uistates.get(hpkg.state, hpkg.state)
if maxlen < len(uistate):
maxlen = len(uistate)
+ if pkg_max_len < len(str(hpkg)):
+ pkg_max_len = len(str(hpkg))
for hpkg in old.trans_data:
prefix = " " * 4
@@ -1813,18 +1838,18 @@ to exit.
hpkg.state == 'Update'):
ln = len(hpkg.name) + 1
cn = (" " * ln) + cn[ln:]
- print "%s%s%s%s %s" % (prefix, hibeg, uistate, hiend, cn)
elif (last is not None and
last.state == 'Downgrade' and last.name == hpkg.name and
hpkg.state == 'Downgraded'):
ln = len(hpkg.name) + 1
cn = (" " * ln) + cn[ln:]
- print "%s%s%s%s %s" % (prefix, hibeg, uistate, hiend, cn)
else:
last = None
if hpkg.state in ('Updated', 'Downgrade'):
last = hpkg
- print "%s%s%s%s %s" % (prefix, hibeg, uistate, hiend, cn)
+ print "%s%s%s%s %-*s %s" % (prefix, hibeg, uistate, hiend,
+ pkg_max_len, cn,
+ self._hpkg2from_repo(hpkg))
def historySummaryCmd(self, extcmds):
tids, printall = self._history_list_transactions(extcmds)
More information about the Yum-commits
mailing list