1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-23 05:26:16 +01:00

add new service commands (merge and wait)

This commit is contained in:
Adrian Schröter 2016-03-03 11:05:48 +01:00
parent ae85d0c464
commit aa74e98fb3
3 changed files with 44 additions and 2 deletions

2
NEWS
View File

@ -9,6 +9,8 @@
- add --linkrev option to branch command
- add --add-repository-block option to branch command
- add --add-repository-rebuild option to branch command
- add service merge command
- add service wait command
0.152
- add support searching for groups via "group:" prefix

View File

@ -6261,6 +6261,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
osc service localrun
osc service disabledrun
osc service remoterun [PROJECT PACKAGE]
osc service merge [PROJECT PACKAGE]
osc service wait [PROJECT PACKAGE]
COMMAND can be:
run r run defined services locally, it takes an optional parameter to run only a
@ -6269,6 +6271,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
localrun lr run services locally and store files as local created
disabledrun dr run disabled or server side only services locally and store files as local created
remoterun rr trigger a re-run on the server side
merge commits all server side generated files and drops the _service definition
wait waits until the service finishes and returns with an error if it failed
${cmd_option_list}
"""
@ -6287,7 +6291,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
raise oscerr.WrongArgs('Too few arguments.')
if len(args) == 2:
singleservice = args[1]
elif len(args) == 3 and args[0] in ('remoterun', 'rr'):
elif len(args) == 3 and args[0] in ('remoterun', 'rr', 'merge', 'wait'):
project = args[1]
package = args[2]
else:
@ -6295,13 +6299,21 @@ Please submit there instead, or use --nodevelproject to force direct submission.
command = args[0]
if not (command in ( 'run', 'localrun', 'disabledrun', 'remoterun', 'lr', 'dr', 'r', 'rr' )):
if not (command in ( 'run', 'localrun', 'disabledrun', 'remoterun', 'lr', 'dr', 'r', 'rr', 'merge', 'wait' )):
raise oscerr.WrongArgs('Wrong command given.')
if command == "remoterun" or command == "rr":
print(runservice(apiurl, project, package))
return
if command == "wait":
print(waitservice(apiurl, project, package))
return
if command == "merge":
print(mergeservice(apiurl, project, package))
return
if command in ('run', 'localrun', 'disabledrun', 'lr', 'dr', 'r'):
if not is_package_dir(os.curdir):
raise oscerr.WrongArgs('Local directory is no package')

View File

@ -5991,6 +5991,34 @@ def runservice(apiurl, prj, package):
root = ET.parse(f).getroot()
return root.get('code')
def waitservice(apiurl, prj, package):
u = makeurl(apiurl, ['source', prj, package], query={'cmd': 'waitservice'})
try:
f = http_POST(u)
except HTTPError as e:
e.osc_msg = 'The service for project \'%s\' package \'%s\' failed' % (prj, package)
raise
root = ET.parse(f).getroot()
return root.get('code')
def mergeservice(apiurl, prj, package):
# first waiting that the service finishes and that it did not fail
waitservice(apiurl, prj, package)
# real merge
u = makeurl(apiurl, ['source', prj, package], query={'cmd': 'mergeservice'})
try:
f = http_POST(u)
except HTTPError as e:
e.osc_msg = 'could not merge service files in 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' }