1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-21 01:36:16 +02:00

Print error for a failed service run in do_submitrequest

Additionally, we do not treat a "running" service run as an
error (the api will complain, if it is still running).
This commit is contained in:
Marcus Huewe 2017-01-31 23:35:43 +01:00
parent 3b3bb21645
commit b0d905aa38

View File

@ -1078,6 +1078,20 @@ class Osc(cmdln.Cmdln):
${cmd_option_list} ${cmd_option_list}
""" """
def _check_service(root):
serviceinfo = root.find('serviceinfo')
if serviceinfo is not None:
# code "running" is ok, because the api will choke when trying
# to create the sr (if it is still running)
if serviceinfo.get('code') not in ('running', 'succeeded'):
print('A service run for package %s %s:'
% (root.get('name'), serviceinfo.get('code')),
file=sys.stderr)
error = serviceinfo.find('error')
if error is not None:
print('\n'.join(error.text.split('\\n')))
sys.exit('\nPlease fix this first')
if opts.cleanup and opts.no_cleanup: if opts.cleanup and opts.no_cleanup:
raise oscerr.WrongOptions('\'--cleanup\' and \'--no-cleanup\' are mutually exclusive') raise oscerr.WrongOptions('\'--cleanup\' and \'--no-cleanup\' are mutually exclusive')
@ -1176,14 +1190,8 @@ class Osc(cmdln.Cmdln):
print("Skipping package ", p, " since it is a source link pointing inside the project.") print("Skipping package ", p, " since it is a source link pointing inside the project.")
continue continue
serviceinfo = root.find('serviceinfo') # check for failed source service
if serviceinfo != None: _check_service(root)
if serviceinfo.get('code') != "succeeded":
print("Package ", p, " has a ", serviceinfo.get('code'), " source service")
sys.exit("Please fix this first")
if serviceinfo.get('error'):
print("Package ", p, " contains a failed source service.")
sys.exit("Please fix this first")
# submitting this package # submitting this package
if opts.separate_requests or opts.seperate_requests: if opts.separate_requests or opts.seperate_requests:
@ -1269,18 +1277,11 @@ class Osc(cmdln.Cmdln):
raise oscerr.WrongArgs('Incorrect number of arguments.\n\n' \ raise oscerr.WrongArgs('Incorrect number of arguments.\n\n' \
+ self.get_cmd_help('request')) + self.get_cmd_help('request'))
# check for running source service # check for failed source service
u = makeurl(apiurl, ['source', src_project, src_package]) u = makeurl(apiurl, ['source', src_project, src_package])
f = http_GET(u) f = http_GET(u)
root = ET.parse(f).getroot() root = ET.parse(f).getroot()
serviceinfo = root.find('serviceinfo') _check_service(root)
if serviceinfo != None:
if serviceinfo.get('code') != "succeeded":
print("Package ", src_package, " has a ", serviceinfo.get('code'), " source service")
sys.exit("Please fix this first")
if serviceinfo.get('error'):
print("Package ", src_package, " contains a failed source service.")
sys.exit("Please fix this first")
if not opts.nodevelproject: if not opts.nodevelproject:
devloc = None devloc = None