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

initial service command for running source services remote or locally

This commit is contained in:
Adrian Schröter 2010-09-01 12:44:47 +02:00
parent 2f544dad9f
commit 11d81fe776
3 changed files with 63 additions and 0 deletions

3
NEWS
View File

@ -1,3 +1,6 @@
0.130
- New "service" command to run source services locally or trigger a re-run on the server.
0.129
- "dists" command to show the configured default base repos from the server.
- "review list" command to list open review requests

View File

@ -4400,6 +4400,53 @@ Please submit there instead, or use --nodevelproject to force direct submission.
log = '\n'.join(get_commitlog(apiurl, project, package, rev, format, opts.meta))
run_pager(log)
def do_service(self, subcmd, opts, *args):
"""${cmd_name}: Handle source services
Source services can be used to modify sources like downloading files,
verify files, generating files or modify existing files.
usage:
osc service COMMAND (inside working copy)
osc service COMMAND PROJECT PACKAGE
COMMAND can be:
run run defined services locally
remoterun trigger a re-run on the server side
${cmd_option_list}
"""
args = slash_split(args)
package = repo = arch = code = None
apiurl = self.get_api_url()
if len(args) < 2:
if is_package_dir(os.curdir):
project = store_read_project(os.curdir)
package = store_read_package(os.curdir)
apiurl = store_read_apiurl(os.curdir)
else:
raise oscerr.WrongArgs('Too few arguments.')
elif len(args) == 3:
project = args[1]
package = args[2]
else:
raise oscerr.WrongArgs('Too few arguments.')
command = args[0]
if command == "remoterun":
print runservice(apiurl, project, package)
if command == "run":
if not is_package_dir(os.curdir):
raise oscerr.WrongArgs('Local directory is no package')
p = Package(".")
p.run_source_services()
@cmdln.option('-f', '--failed', action='store_true',
help='rebuild all failed packages')
@cmdln.alias('rebuildpac')

View File

@ -4464,6 +4464,19 @@ def get_commitlog(apiurl, prj, package, revision, format = 'text', meta = False)
return r
def runservice(apiurl, prj, package):
u = makeurl(apiurl, ['source', prj, package], query={'cmd': 'runservice'})
try:
f = http_POST(u)
except urllib2.HTTPError, e:
e.osc_msg = 'could not trigger service run for project \'%s\' package \'%s\'' % (prj, package)
raise
root = ET.parse(f).getroot()
return root.get('code')
def rebuild(apiurl, prj, package, repo, arch, code=None):
query = { 'cmd': 'rebuild' }
if package: