From bd82e236ee2023b84019282a0cc1d0e692af4398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Thu, 11 Sep 2014 11:25:24 +0200 Subject: [PATCH] - display request priorities, if important or critical - add "osc rq priorize" command to re-priorize existing requests - allow also "osc rq ls" shortcut --- NEWS | 3 +++ osc/commandline.py | 20 ++++++++++++++++++-- osc/core.py | 9 ++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index bf7aab69..11388977 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ 0.148 - support new history including review history of OBS 2.6 + - display request priorities, if important or critical + - add "osc rq priorize" command to re-priorize existing requests + - allow also "osc rq ls" shortcut 0.147 - support groups in maintainership requests diff --git a/osc/commandline.py b/osc/commandline.py index d5ba9736..00d11f04 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -1958,6 +1958,9 @@ Please submit there instead, or use --nodevelproject to force direct submission. "checkout" will checkout the request's source package ("submit" requests only). + "priorize" change the prioritity of a request to either "critical", "important", "moderate" or "low" + + The 'review' command has the following sub commands: "list" lists open requests that need to be reviewed by the @@ -1982,6 +1985,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. osc request setincident [-m TEXT] ID INCIDENT osc request supersede [-m TEXT] ID SUPERSEDING_ID osc request approvenew [-m TEXT] PROJECT + osc request priorize [-m TEXT] ID PRIORITY osc request checkout/co ID osc request clone [-m TEXT] ID @@ -2021,7 +2025,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. if args[0] == 'help': return self.do_help(['help', 'request']) - cmds = ['list', 'log', 'show', 'decline', 'reopen', 'clone', 'accept', 'approvenew', 'wipe', 'setincident', 'supersede', 'revoke', 'checkout', 'co'] + cmds = ['list', 'ls', 'log', 'show', 'decline', 'reopen', 'clone', 'accept', 'approvenew', 'wipe', 'setincident', 'supersede', 'revoke', 'checkout', 'co', 'priorize'] if subcmd != 'review' and args[0] not in cmds: raise oscerr.WrongArgs('Unknown request action %s. Choose one of %s.' \ % (args[0], ', '.join(cmds))) @@ -2032,12 +2036,14 @@ Please submit there instead, or use --nodevelproject to force direct submission. cmd = args[0] del args[0] + if cmd == 'ls': + cmd = "list" apiurl = self.get_api_url() if cmd in ['list']: min_args, max_args = 0, 2 - elif cmd in ['supersede', 'setincident']: + elif cmd in ['supersede', 'setincident', 'priorize']: min_args, max_args = 2, 2 else: min_args, max_args = 1, 1 @@ -2074,6 +2080,9 @@ Please submit there instead, or use --nodevelproject to force direct submission. elif cmd == 'setincident': reqid = args[0] incident = args[1] + elif cmd == 'priorize': + reqid = args[0] + priority = args[1] elif cmd in ['log', 'add', 'show', 'decline', 'reopen', 'clone', 'accept', 'wipe', 'revoke', 'checkout', 'co']: reqid = args[0] @@ -2089,6 +2098,13 @@ Please submit there instead, or use --nodevelproject to force direct submission. r = http_POST(url, data=opts.message) print(ET.parse(r).getroot().get('code')) + # change priority + elif cmd == 'priorize': + query = { 'cmd': 'setpriority', 'priority': priority } + url = makeurl(apiurl, ['request', reqid], query) + r = http_POST(url, data=opts.message) + print(ET.parse(r).getroot().get('code')) + # add new reviewer to existing request elif cmd in ['add'] and subcmd == 'review': query = { 'cmd': 'addreview' } diff --git a/osc/core.py b/osc/core.py index 3692987f..bd87ac02 100644 --- a/osc/core.py +++ b/osc/core.py @@ -2581,6 +2581,7 @@ class Request: self.reqid = None self.title = '' self.description = '' + self.priority = None self.state = None self.accept_at = None self.actions = [] @@ -2608,6 +2609,8 @@ class Request: self.reviews.append(ReviewState(review)) for history_element in root.findall('history'): self.statehistory.append(RequestHistory(history_element)) + if not root.find('priority') is None: + self.priority = root.find('priority').text.strip() if not root.find('accept_at') is None and root.find('accept_at').text: self.accept_at = root.find('accept_at').text.strip() if not root.find('title') is None: @@ -2653,6 +2656,8 @@ class Request: ET.SubElement(root, 'description').text = self.description if self.accept_at: ET.SubElement(root, 'accept_at').text = self.accept_at + if self.priority: + ET.SubElement(root, 'priority').text = self.priority return root def to_str(self): @@ -2779,7 +2784,7 @@ class Request: tmpl = ' Review by %(type)-10s is %(state)-10s %(by)-50s' for review in self.reviews: lines.append(tmpl % Request.format_review(review)) - history = ['%s(%s)' % (hist.name, hist.who) for hist in self.statehistory] + history = ['%s: %s' % (hist.description, hist.who) for hist in self.statehistory] if history: lines.append(' From: %s' % ' -> '.join(history)) if self.description: @@ -2794,6 +2799,8 @@ class Request: lines = ['Request: #%s\n' % self.reqid] if self.accept_at and self.state.name in [ 'new', 'review' ]: lines.append(' *** This request will get automatically accepted after '+self.accept_at+' ! ***\n') + if self.priority in [ 'critical', 'important' ] and self.state.name in [ 'new', 'review' ]: + lines.append(' *** This request has classified as '+self.priority+' ! ***\n') for action in self.actions: tmpl = ' %(type)-13s %(source)s %(target)s'