Skip to content

Commit

Permalink
- support restartbuild and abortbuild
Browse files Browse the repository at this point in the history
small refactoring but keep api compability
  • Loading branch information
adrianschroeter committed Oct 28, 2013
1 parent 4349917 commit 67802e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
17 changes: 9 additions & 8 deletions osc/commandline.py
Expand Up @@ -6027,16 +6027,17 @@ def do_info(self, subcmd, opts, *args):


@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)
Expand Down Expand Up @@ -6071,9 +6072,9 @@ def do_abortbuild(self, subcmd, opts, *args):
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',
Expand Down
31 changes: 8 additions & 23 deletions osc/core.py
Expand Up @@ -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:
Expand Down

0 comments on commit 67802e6

Please sign in to comment.