1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-11 16:36:14 +01:00

- handle errors of source service runs

This commit is contained in:
Adrian Schröter 2011-05-24 10:49:08 +02:00
parent 0a7492cdf8
commit c00751f4d7
3 changed files with 21 additions and 5 deletions

View File

@ -4727,9 +4727,14 @@ Please submit there instead, or use --nodevelproject to force direct submission.
args = self.parse_repoarchdescr(args, opts.noinit or opts.offline, opts.alternative_project) args = self.parse_repoarchdescr(args, opts.noinit or opts.offline, opts.alternative_project)
# check for source services # check for source services
if not opts.noservice and not opts.noinit and os.listdir('.').count("_service"): if not opts.noservice and not opts.noinit:
p = Package('.') p = Package('.')
p.run_source_services() r = p.run_source_services()
if r != 0:
print >>sys.stderr, 'Source service run failed!'
sys.exit(1)
# that is currently unreadable on cli, we should not have a backtrace on standard errors:
#raise oscerr.ServiceRuntimeError('Service run failed: \'%s\'', r)
if conf.config['no_verify']: if conf.config['no_verify']:
opts.no_verify = True opts.no_verify = True

View File

@ -317,6 +317,7 @@ class Serviceinfo:
allservices = [data] allservices = [data]
# recreate files # recreate files
ret = 0
for service in allservices: for service in allservices:
if singleservice and service['name'] != singleservice: if singleservice and service['name'] != singleservice:
continue continue
@ -332,12 +333,13 @@ class Serviceinfo:
c = "/usr/lib/obs/service/" + call + " --outdir " + temp_dir c = "/usr/lib/obs/service/" + call + " --outdir " + temp_dir
if conf.config['verbose'] > 1: if conf.config['verbose'] > 1:
print "Run source service:", c print "Run source service:", c
ret = subprocess.call(c, shell=True) r = subprocess.call(c, shell=True)
if ret != 0: if r != 0:
print "ERROR: service call failed: " + c print "ERROR: service call failed: " + c
# FIXME: addDownloadUrlService calls si.execute after # FIXME: addDownloadUrlService calls si.execute after
# updating _services. # updating _services.
print " (your _services file may be corrupt now)" print " (your _services file may be corrupt now)"
ret = r
if service['mode'] == "disabled" or service['mode'] == "trylocal" or service['mode'] == "localonly" or callmode == "local": if service['mode'] == "disabled" or service['mode'] == "trylocal" or service['mode'] == "localonly" or callmode == "local":
for filename in os.listdir(temp_dir): for filename in os.listdir(temp_dir):
@ -347,6 +349,8 @@ class Serviceinfo:
shutil.move( os.path.join(temp_dir, filename), os.path.join(dir, "_service:"+name+":"+filename) ) shutil.move( os.path.join(temp_dir, filename), os.path.join(dir, "_service:"+name+":"+filename) )
os.rmdir(temp_dir) os.rmdir(temp_dir)
return ret
class Linkinfo: class Linkinfo:
"""linkinfo metadata (which is part of the xml representing a directory """linkinfo metadata (which is part of the xml representing a directory
""" """
@ -2045,8 +2049,9 @@ rev: %s
service = ET.parse(os.path.join(self.absdir, '_service')).getroot() service = ET.parse(os.path.join(self.absdir, '_service')).getroot()
si.read(service) si.read(service)
si.getProjectGlobalServices(self.apiurl, self.prjname, self.name) si.getProjectGlobalServices(self.apiurl, self.prjname, self.name)
si.execute(self.absdir, mode, singleservice) r = si.execute(self.absdir, mode, singleservice)
os.chdir(curdir) os.chdir(curdir)
return r
def prepare_filelist(self): def prepare_filelist(self):
"""Prepare a list of files, which will be processed by process_filelist """Prepare a list of files, which will be processed by process_filelist

View File

@ -48,6 +48,12 @@ class ExtRuntimeError(OscBaseError):
self.msg = msg self.msg = msg
self.file = fname self.file = fname
class ServiceRuntimeError(OscBaseError):
"""Exception raised when there is source service error runtime error"""
def __init__(self, msg):
OscBaseError.__init__(self)
self.msg = msg
class WrongArgs(OscBaseError): class WrongArgs(OscBaseError):
"""Exception raised by the cli for wrong arguments usage""" """Exception raised by the cli for wrong arguments usage"""