1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-10 06:46:15 +01:00

- support restartbuild and abortbuild

small refactoring but keep api compability
This commit is contained in:
Adrian Schröter 2013-10-28 18:29:56 +01:00
parent 43499172af
commit 67802e6a41
2 changed files with 17 additions and 31 deletions

View File

@ -6027,16 +6027,17 @@ Please submit there instead, or use --nodevelproject to force direct submission.
@cmdln.option('-a', '--arch', metavar='ARCH',
help='Abort builds for a specific architecture')
help='Restart builds for a specific architecture')
@cmdln.option('-r', '--repo', metavar='REPO',
help='Abort builds for a specific repository')
help='Restart builds for a specific repository')
@cmdln.option('--all', action='store_true',
help='Abort all running builds of entire project')
def do_abortbuild(self, subcmd, opts, *args):
"""${cmd_name}: Aborts the build of a certain project or package
help='Restart all running builds of entire project')
@cmdln.alias('abortbuild')
def do_restartbuild(self, subcmd, opts, *args):
"""${cmd_name}: Restart the build of a certain project or package
usage:
osc abortbuild [PROJECT [PACKAGE [REPOSITORY [ARCH]]]]
osc restartbuild [PROJECT [PACKAGE [REPOSITORY [ARCH]]]]
${cmd_option_list}
"""
args = slash_split(args)
@ -6071,9 +6072,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
arch = args[3]
if not (opts.all or package or repo or arch):
raise oscerr.WrongOptions('No option has been provided. If you want to abort all packages of the entire project, use --all option.')
raise oscerr.WrongOptions('No option has been provided. If you want to restart all packages of the entire project, use --all option.')
print(abortbuild(apiurl, project, package, opts.arch, opts.repo))
print(cmdbuild(apiurl, subcmd, project, package, opts.arch, opts.repo))
@cmdln.option('-a', '--arch', metavar='ARCH',

View File

@ -5671,32 +5671,17 @@ def get_osc_version():
def abortbuild(apiurl, project, package=None, arch=None, repo=None):
query = { 'cmd': 'abortbuild' }
if package:
query['package'] = package
if arch:
query['arch'] = arch
if repo:
query['repository'] = repo
u = makeurl(apiurl, ['build', project], query)
try:
f = http_POST(u)
except HTTPError as e:
e.osc_msg = 'abortion failed for project %s' % project
if package:
e.osc_msg += ' package %s' % package
if arch:
e.osc_msg += ' arch %s' % arch
if repo:
e.osc_msg += ' repo %s' % repo
raise
return cmdbuild(apiurl, 'abortbuild', project, package, arch, repo)
root = ET.parse(f).getroot()
return root.get('code')
def restartbuild(apiurl, project, package=None, arch=None, repo=None):
return cmdbuild(apiurl, 'restartbuild', project, package, arch, repo)
def wipebinaries(apiurl, project, package=None, arch=None, repo=None):
return cmdbuild(apiurl, 'wipebinaries', project, package, arch, repo)
def wipebinaries(apiurl, project, package=None, arch=None, repo=None, code=None):
query = { 'cmd': 'wipe' }
def cmdbuild(apiurl, cmd, project, package=None, arch=None, repo=None, code=None):
query = { 'cmd': cmd }
if package:
query['package'] = package
if arch: