From cde0c2765df41e10da16b0bfb78c170cc421234d Mon Sep 17 00:00:00 2001 From: Morgan Fainberg Date: Fri, 19 Apr 2013 16:18:15 -0700 Subject: [PATCH] Fix for #4514 Cleaning up warning/error messages for issue #4514. There are now log messages when either aptsources.sourceslist or softwareproperties.ppa fail to import. There are also clearer log warnings when trying to use functions from either. --- salt/modules/apt.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/salt/modules/apt.py b/salt/modules/apt.py index 835e8f5e49..5e84ad77db 100644 --- a/salt/modules/apt.py +++ b/salt/modules/apt.py @@ -12,19 +12,25 @@ import json # Import salt libs import salt.utils + +log = logging.getLogger(__name__) + + try: from aptsources import sourceslist apt_support = True -except ImportError: +except ImportError, e: apt_support = False + err_str = 'Unable to import "sourceslist" from "aptsources" module: {0}' + log.error(err_str.format(str(e))) try: import softwareproperties.ppa ppa_format_support = True -except ImportError: +except ImportError, e: ppa_format_support = False - -log = logging.getLogger(__name__) + err_str = 'Unable to import "softwareproperties.ppa": {0}' + log.warning(err_str.format(str(e))) # Source format for urllib fallback on PPA handling LP_SRC_FORMAT = 'deb http://ppa.launchpad.net/{0}/{1}/ubuntu {2} main' @@ -774,8 +780,9 @@ def del_repo(repo, refresh=False, **kwargs): is_ppa = True dist = __grains__['lsb_codename'] if not ppa_format_support: - warning_str = 'python-software-properties package not ' \ - 'installed, making best guess at ppa format: {0}' + warning_str = 'Unable to use functions from ' \ + '"python-software-properties" package, making ' \ + 'best guess at ppa format: {0}' log.warning(warning_str.format(repo)) owner_name, ppa_name = repo[4:].split('/') if 'ppa_auth' in kwargs: @@ -898,8 +905,9 @@ def mod_repo(repo, refresh=False, **kwargs): return {repo: out} else: if not ppa_format_support: - log.warning('software-python-properties not installed, ' - 'falling back to using urllib method for PPA.') + log.warning('Unable to use functions from ' + '"python-software-properties" package, making ' + 'best guess at ppa format: {0}') else: log.info('falling back to urllib method for private PPA ') #fall back to urllib style