summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins/Packages/Source.py
diff options
context:
space:
mode:
authorMike McCallister <mike@mccllstr.com>2011-10-15 22:06:31 -0500
committerMike McCallister <mike@mccllstr.com>2011-10-15 23:41:21 -0500
commit826f385767ccf9f608fcfbe35e381a9dbc59db4b (patch)
tree2320daecca65d435d78e37f4fd213cd41119a07a /src/lib/Server/Plugins/Packages/Source.py
parent17a031da6ec2ee448ee3d8e18dde5c6a3785c464 (diff)
downloadbcfg2-826f385767ccf9f608fcfbe35e381a9dbc59db4b.tar.gz
bcfg2-826f385767ccf9f608fcfbe35e381a9dbc59db4b.tar.bz2
bcfg2-826f385767ccf9f608fcfbe35e381a9dbc59db4b.zip
Improve error handling of Packages plugin.
Provide a descriptive error message that avoids logging a traceback. Error out (instead of continuing) upon receiving an HTTP error or an indication that the URL is malformed. Only write data to the cache file if it was successfully retrieved from the URL. Make log messages for Packages plugin use consistent "Packages:" prefix.
Diffstat (limited to 'src/lib/Server/Plugins/Packages/Source.py')
-rw-r--r--src/lib/Server/Plugins/Packages/Source.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/Server/Plugins/Packages/Source.py b/src/lib/Server/Plugins/Packages/Source.py
index 255f3ea7a..00018ef9a 100644
--- a/src/lib/Server/Plugins/Packages/Source.py
+++ b/src/lib/Server/Plugins/Packages/Source.py
@@ -109,7 +109,7 @@ class Source(object):
self.load_state()
should_read = False
except:
- logger.error("Cachefile %s load failed; "
+ logger.error("Packages: Cachefile %s load failed; "
"falling back to file read" % self.cachefile)
if should_read:
try:
@@ -124,7 +124,9 @@ class Source(object):
self.update()
self.read_files()
except:
- logger.error("Failed to update source", exc_info=1)
+ logger.error("Packages: Failed to load data for Source of %s. "
+ "Some Packages will be missing."
+ % self.urls)
def get_repo_name(self, url_map):
# try to find a sensible name for a repo
@@ -192,15 +194,15 @@ class Source(object):
fname = self.escape_url(url)
try:
data = fetch_url(url)
+ file(fname, 'w').write(data)
except ValueError:
logger.error("Packages: Bad url string %s" % url)
- continue
+ raise
except HTTPError:
err = sys.exc_info()[1]
- logger.error("Packages: Failed to fetch url %s. code=%s" %
+ logger.error("Packages: Failed to fetch url %s. HTTP response code=%s" %
(url, err.code))
- continue
- file(fname, 'w').write(data)
+ raise
def applies(self, metadata):
# check base groups