From 8ffddf2cdc52839deafefa37c78607d01121bcc1 Mon Sep 17 00:00:00 2001 From: Will Woods Date: Fri, 20 Feb 2009 17:07:28 -0500 Subject: Handle problems with downloadPkgs --- debuginfofs-mirror | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/debuginfofs-mirror b/debuginfofs-mirror index 5993b41..0aead68 100755 --- a/debuginfofs-mirror +++ b/debuginfofs-mirror @@ -21,18 +21,19 @@ import os import sys import shutil -import logging import optparse import ConfigParser import rpmUtils.arch # Why, yes, I do like to arrange imports by line length from subprocess import Popen, PIPE -from yum import _ +# Yum stuff +sys.path.insert(0,'/usr/share/yum-cli') +import yum.misc import yum.Errors +from yum import _ +from utils import YumUtilBase from yum.parser import varReplace from yum.yumRepo import YumRepository -sys.path.insert(0,'/usr/share/yum-cli') -from utils import YumUtilBase configfile = '/etc/debuginfofs.conf' c = ConfigParser.RawConfigParser() @@ -277,6 +278,7 @@ if __name__ == '__main__': else: needpackages.append(p) + if not needpackages: y.verbose_logger.info(_('Nothing to do!')) sys.exit(0) @@ -292,13 +294,21 @@ if __name__ == '__main__': sys.exit(1) # Download packages - y.downloadPkgs(needpackages, callback_total=y.download_callback_total_cb) + problems = y.downloadPkgs(needpackages, + callback_total=y.download_callback_total_cb) + if problems: + msg = _('Error Downloading Packages:\n') + for key, val in problems.iteritems() + errors = yum.misc.unique(val) + for e in errors: + msg += ' %s: %s\n' % (key, e) + raise yum.Errors.YumBaseError, msg # Unpack and hardlink downloaded RPMs for p in needpackages: local = p.localpath - (n,a,e,v,r) = p.pkgtup - nevra = "%s-%s:%s-%s.%s" % (n,e,v,r,a) + n = p.pkgtup[0] + nevra = pkg_to_nevra(p) newdir = os.path.join(n[0],n,nevra) targetdir = os.path.join(opt.exportdir,'packages',newdir) -- cgit