From b33577b6a700b14e0a1fcb6f59ad6ff27abddff6 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Tue, 29 Mar 2011 17:15:35 +0200 Subject: [PATCH] use more generic oscerr.PackageNotInstalled --- osc/babysitter.py | 6 +++++- osc/core.py | 4 +--- osc/oscerr.py | 12 +++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/osc/babysitter.py b/osc/babysitter.py index 69b909e0..0550f265 100644 --- a/osc/babysitter.py +++ b/osc/babysitter.py @@ -158,7 +158,7 @@ def run(prg): print >>sys.stderr, e.msg return 1 - except oscerr.ServiceNotInstalled, e: + except oscerr.PackageNotInstalled, e: print >>sys.stderr, e.msg return 1 @@ -207,4 +207,8 @@ def run(prg): print >>sys.stderr, e return 1 + except oscerr.OscBaseError, e: + print >>sys.stderr, '*** Error:', e + return 1 + # vim: sw=4 et diff --git a/osc/core.py b/osc/core.py index f41661e1..7fa0b6bf 100644 --- a/osc/core.py +++ b/osc/core.py @@ -328,9 +328,7 @@ class Serviceinfo: temp_dir = tempfile.mkdtemp() name = call.split(None, 1)[0] if not os.path.exists("/usr/lib/obs/service/"+name): - msg = "ERROR: service is not installed!\n" - msg += "Maybe try this: zypper in obs-service-" + name - raise oscerr.ServiceNotInstalled(msg) + raise oscerr.PackageNotInstalled("obs-service-"+name) c = "/usr/lib/obs/service/" + call + " --outdir " + temp_dir if conf.config['verbose'] > 1: print "Run source service:", c diff --git a/osc/oscerr.py b/osc/oscerr.py index 524ca182..f523b92a 100644 --- a/osc/oscerr.py +++ b/osc/oscerr.py @@ -101,13 +101,15 @@ class OscIOError(OscBaseError): self.e = e self.msg = msg -class ServiceNotInstalled(OscBaseError): +class PackageNotInstalled(OscBaseError): """ - Exception raised when a service is not installed on local system + Exception raised when a package is not installed on local system """ - def __init__(self, msg): - OscBaseError.__init__(self) - self.msg = msg + def __init__(self, pkg): + OscBaseError.__init__(self, pkg) + + def __str__(self): + return 'Package %s is required for this operation' % ''.join(self.args) class SignalInterrupt(Exception): """Exception raised on SIGTERM and SIGHUP."""