[yum-commits] Branch 'yum-3_2_X' - output.py yum/history.py
James Antill
james at osuosl.org
Tue Oct 13 14:01:41 UTC 2009
output.py | 14 +++++++++++++-
yum/history.py | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 1 deletion(-)
New commits:
commit eb85347542287c79bfef5ffbc619420f08eaa6d8
Author: James Antill <james at and.org>
Date: Mon Oct 12 17:31:17 2009 -0400
Show scriptlet-output and errors in history info
This WFM(tm), but I've only tested it by adding stuff to my sqlite
manually.
diff --git a/output.py b/output.py
index da84221..e462646 100755
--- a/output.py
+++ b/output.py
@@ -1389,7 +1389,7 @@ to exit.
print _("Return-Code :"), _("Failure:"), old.return_code
else:
print _("Return-Code :"), _("Success")
- print _("Transaction performed with :")
+ print _("Transaction performed with:")
for hpkg in old.trans_with:
prefix = " " * 4
state = _('Installed')
@@ -1408,6 +1408,18 @@ to exit.
print "%s%-12s %s" % (prefix, state, hpkg)
print _("Packages Altered:")
self.historyInfoCmdPkgsAltered(old, pats)
+ if old.output:
+ print _("Scriptlet output:")
+ num = 0
+ for line in old.output:
+ num += 1
+ print "%4d" % num, line
+ if old.errors:
+ print _("Errors:")
+ num = 0
+ for line in old.errors:
+ num += 1
+ print "%4d" % num, line
def historyInfoCmdPkgsAltered(self, old, pats=[]):
for hpkg in old.trans_data:
diff --git a/yum/history.py b/yum/history.py
index 97571c5..85613e1 100644
--- a/yum/history.py
+++ b/yum/history.py
@@ -152,6 +152,9 @@ class YumHistoryTransaction:
self._loaded_TW = None
self._loaded_TD = None
+ self._loaded_ER = None
+ self._loaded_OT = None
+
self.altered_lt_rpmdb = None
self.altered_gt_rpmdb = None
@@ -177,6 +180,18 @@ class YumHistoryTransaction:
trans_with = property(fget=lambda self: self._getTransWith())
trans_data = property(fget=lambda self: self._getTransData())
+ def _getErrors(self):
+ if self._loaded_ER is None:
+ self._loaded_ER = self._history._load_errors(self.tid)
+ return self._loaded_ER
+ def _getOutput(self):
+ if self._loaded_OT is None:
+ self._loaded_OT = self._history._load_output(self.tid)
+ return self._loaded_OT
+
+ errors = property(fget=lambda self: self._getErrors())
+ output = property(fget=lambda self: self._getOutput())
+
class YumHistory:
""" API for accessing the history sqlite data. """
@@ -371,6 +386,28 @@ class YumHistory:
(tid, line) VALUES (?, ?)""", (self._tid, error))
self._commit()
+ def _load_errors(self, tid):
+ cur = self._get_cursor()
+ executeSQL(cur,
+ """SELECT msg FROM trans_error
+ WHERE tid = ?
+ ORDER BY mid ASC""", (tid,))
+ ret = []
+ for row in cur:
+ ret.append(row[0])
+ return ret
+
+ def _load_output(self, tid):
+ cur = self._get_cursor()
+ executeSQL(cur,
+ """SELECT line FROM trans_script_stdout
+ WHERE tid = ?
+ ORDER BY lid ASC""", (tid,))
+ ret = []
+ for row in cur:
+ ret.append(row[0])
+ return ret
+
def end(self, rpmdb_version, return_code, errors=None):
assert return_code or not errors
cur = self._get_cursor()
More information about the Yum-commits
mailing list