From 6eac27ec1c54086f8fd92d85e13ec946eec16831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Tue, 12 Feb 2019 10:15:01 +0100 Subject: [PATCH] support different token operations (runservice, release and rebuild) (requires OBS 2.10) --- NEWS | 4 ++-- osc/commandline.py | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 3504b6de..5e067b8d 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,5 @@ -0.165.2 - - +0.166 + - support different token operations (runservice, release and rebuild) (requires OBS 2.10) 0.165.1 - fix oscssl "urldefrag is not defined error" diff --git a/osc/commandline.py b/osc/commandline.py index d34f9c9e..44cd7dbc 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -728,6 +728,8 @@ class Osc(cmdln.Cmdln): help='Create a new token') @cmdln.option('-d', '--delete', metavar='TOKENID', help='Delete a token') + @cmdln.option('-o', '--operation', metavar='OPERATION', + help='Default is "runservice", but "release" or "rebuild" can also be used') @cmdln.option('-t', '--trigger', metavar='TOKENSTRING', help='Trigger the action of a token') def do_token(self, subcmd, opts, *args): @@ -738,9 +740,9 @@ class Osc(cmdln.Cmdln): Usage: osc token - osc token --create [ ] + osc token --create [--operation ] [ ] osc token --delete - osc token --trigger + osc token --trigger [--operation ] [ ] ${cmd_option_list} """ @@ -752,6 +754,8 @@ class Osc(cmdln.Cmdln): if opts.create: print("Create a new token") url += "?cmd=create" + if opts.operation: + url += "&operation=" + opts.operation if len(args) > 1: url += "&project=" + args[0] url += "&package=" + args[1] @@ -769,7 +773,11 @@ class Osc(cmdln.Cmdln): http_DELETE(url) elif opts.trigger: print("Trigger token") - url = apiurl + "/trigger/runservice" + operation = opts.operation or "runservice" + url = apiurl + "/trigger/" + operation + if len(args) > 1: + url += "?project=" + args[0] + url += "&package=" + args[1] req = URLRequest(url) req.get_method = lambda: "POST" req.add_header('Content-Type', 'application/octet-stream')