From 63ecef1656352ac0ab02290e89830e259914f279 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Thu, 23 Apr 2009 20:34:25 +0000 Subject: Packages: improve error handing (Patch from Tim Laszlo) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5175 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Plugins/Packages.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lib/Server/Plugins/Packages.py b/src/lib/Server/Plugins/Packages.py index 2b00d68b6..54f5be9e7 100644 --- a/src/lib/Server/Plugins/Packages.py +++ b/src/lib/Server/Plugins/Packages.py @@ -1,4 +1,4 @@ -import copy, gzip, lxml.etree, re, urllib +import copy, gzip, lxml.etree, re, urllib2 import os import Bcfg2.Server.Plugin @@ -45,7 +45,7 @@ class Source(object): for url in self.urls: print "updating", url fname = self.mk_fname(url) - data = urllib.urlopen(url).read() + data = urllib2.urlopen(url).read() file(fname, 'w').write(data) def applies(self, metadata): @@ -313,8 +313,11 @@ class Packages(Bcfg2.Server.Plugin.Plugin, source.read_files() except: self.logger.info("File read failed; updating sources", exc_info=1) - source.update() - source.read_files() + try: + source.update() + source.read_files() + except IOError, e: + self.logger.error("Failed to update sources: " + str(e.code)) self.sentinels.update(source.basegroups) def get_matching_sources(self, meta): -- cgit v1.2.3-1-g7c22