[yum-commits] 2 commits - cli.py yum/__init__.py yummain.py
zpavlas at osuosl.org
zpavlas at osuosl.org
Tue Mar 6 15:54:01 UTC 2012
cli.py | 5 +++++
yum/__init__.py | 1 +
yummain.py | 6 +++---
3 files changed, 9 insertions(+), 3 deletions(-)
New commits:
commit e16d0627196ce891ccab049f08dd24081f45e439
Author: ZdenÄk Pavlas <zpavlas at redhat.com>
Date: Tue Mar 6 16:53:43 2012 +0100
exit(1) when all reinstall args are bad. BZ 800285.
diff --git a/cli.py b/cli.py
index ffc1741..0ccb98e 100755
--- a/cli.py
+++ b/cli.py
@@ -1094,6 +1094,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
oldcount = len(self.tsInfo)
+ done = False
for arg in userlist:
if (arg.endswith('.rpm') and (yum.misc.re_remote_url(arg) or
os.path.exists(arg))):
@@ -1120,11 +1121,15 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
assert False, "Shouldn't happen, but just in case"
self.verbose_logger.log(yum.logginglevels.INFO_2, e)
else:
+ done = True
self._install_upgraded_requires(txmbrs)
if len(self.tsInfo) > oldcount:
change = len(self.tsInfo) - oldcount
return 2, [P_('%d package to reinstall', '%d packages to reinstall', change) % change]
+
+ if not done:
+ return 1, [_('Nothing to do')]
return 0, [_('Nothing to do')]
def localInstall(self, filelist, updateonly=0):
commit 9a982cb04ee585e64010bf8885c3f8868552935f
Author: ZdenÄk Pavlas <zpavlas at redhat.com>
Date: Tue Mar 6 16:53:06 2012 +0100
Allow changing the exit code on non-fatal errors.
Currently, doCommand() may return result=1 to indicate a fatal error,
or result=0/2 to signal success. Minor errors are usually handled just
by printing an error message, but they can't change the exit code.
Use a read-write attribute instead of 0 as the exit code, so that minor
errors can change it without disturbing the control flow.
diff --git a/yum/__init__.py b/yum/__init__.py
index fab3553..eb946d9 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -210,6 +210,7 @@ class YumBase(depsolve.Depsolve):
self.run_with_package_names = set()
self._cleanup = []
+ self.exit_code = 0
def __del__(self):
self.close()
diff --git a/yummain.py b/yummain.py
index e1a9702..c473df6 100755
--- a/yummain.py
+++ b/yummain.py
@@ -160,7 +160,7 @@ def main(args):
for msg in resultmsgs:
verbose_logger.log(logginglevels.INFO_2, '%s', msg)
if unlock(): return 200
- return 0
+ return base.exit_code
elif result == 1:
# Fatal error
for msg in resultmsgs:
@@ -199,7 +199,7 @@ def main(args):
if result == 0:
# Normal exit
if unlock(): return 200
- return 0
+ return base.exit_code
elif result == 1:
# Fatal error
for msg in resultmsgs:
@@ -257,7 +257,7 @@ def main(args):
verbose_logger.log(logginglevels.INFO_2, _('Complete!'))
if unlock(): return 200
- return return_code
+ return return_code or base.exit_code
def hotshot(func, *args, **kwargs):
"""Profile the given function using the hotshot profiler.
More information about the Yum-commits
mailing list