From 84e75831c00b6f4b7de1278b07da1e23fe6fdd35 Mon Sep 17 00:00:00 2001 From: Jorge Schrauwen Date: Fri, 31 Jul 2015 17:08:40 +0000 Subject: [PATCH 1/2] pkgin module should not throw exception in _check_pkgin incase pkg_info is missing --- salt/modules/pkgin.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/salt/modules/pkgin.py b/salt/modules/pkgin.py index 677566a0ba..b8fcdefb44 100644 --- a/salt/modules/pkgin.py +++ b/salt/modules/pkgin.py @@ -32,15 +32,17 @@ def _check_pkgin(): ppath = salt.utils.which('pkgin') if ppath is None: # pkgin was not found in $PATH, try to find it via LOCALBASE - localbase = __salt__['cmd.run']( - 'pkg_info -Q LOCALBASE pkgin', - output_loglevel='trace' - ) - if localbase is not None: - ppath = '{0}/bin/pkgin'.format(localbase) - if not os.path.exists(ppath): - return None - + try: + localbase = __salt__['cmd.run']( + 'pkg_info -Q LOCALBASE pkgin', + output_loglevel='trace' + ) + if localbase is not None: + ppath = '{0}/bin/pkgin'.format(localbase) + if not os.path.exists(ppath): + return None + except: + return None return ppath From 33e0f28f2919fd8b24cec8d3fb71d600a9ab4965 Mon Sep 17 00:00:00 2001 From: Jorge Schrauwen Date: Fri, 31 Jul 2015 19:31:47 +0000 Subject: [PATCH 2/2] try to pass pylint, catch only the correct exception --- salt/modules/pkgin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/pkgin.py b/salt/modules/pkgin.py index b8fcdefb44..3e59b24782 100644 --- a/salt/modules/pkgin.py +++ b/salt/modules/pkgin.py @@ -41,7 +41,7 @@ def _check_pkgin(): ppath = '{0}/bin/pkgin'.format(localbase) if not os.path.exists(ppath): return None - except: + except CommandExecutionError: return None return ppath