diff --git a/NEWS b/NEWS index 023551dd..f1856f65 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/osc/commandline.py b/osc/commandline.py index 19894ac3..2abe4f70 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -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') diff --git a/osc/core.py b/osc/core.py index cbfbc2d0..5ca90be5 100644 --- a/osc/core.py +++ b/osc/core.py @@ -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' }