From f202fbd1117c6d0bf808cccb29f9940a9c300e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Thu, 5 Dec 2013 10:23:53 +0100 Subject: [PATCH] add option for deleterequests using auto-accept --- NEWS | 1 + osc/commandline.py | 4 ++++ osc/core.py | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/NEWS b/NEWS index b0bb3ced..f701bdfa 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ 0.143 + - add option to add a auto-accept in future for delete requests (handy for admins) 0.142 - ppc64p7 build support diff --git a/osc/commandline.py b/osc/commandline.py index da5ae41f..f51eeb93 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -1740,6 +1740,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. help='specify message TEXT') @cmdln.option('-r', '--repository', metavar='TEXT', help='specify message TEXT') + @cmdln.option('--accept-in-hours', metavar='TEXT', + help='specify message time when request shall get accepted automatically. Only works with write permissions in target.') @cmdln.alias("dr") @cmdln.alias("dropreq") @cmdln.alias("droprequest") @@ -1793,6 +1795,8 @@ Please submit there instead, or use --nodevelproject to force direct submission. r = Request() r.add_action('delete', tgt_project=project, tgt_package=package, tgt_repository=repository) r.description = cgi.escape(opts.message) + if opts.accept_in_hours: + r.accept_at_in_hours(int(opts.accept_in_hours)) r.create(self.get_api_url()) print(r.reqid) diff --git a/osc/core.py b/osc/core.py index 9a90f4c4..2af072e0 100644 --- a/osc/core.py +++ b/osc/core.py @@ -2480,6 +2480,8 @@ class Request: ET.SubElement(root, 'title').text = self.title if self.description: ET.SubElement(root, 'description').text = self.description + if self.accept_at: + ET.SubElement(root, 'accept_at').text = self.accept_at return root def to_str(self): @@ -2488,6 +2490,14 @@ class Request: xmlindent(root) return ET.tostring(root, encoding=ET_ENCODING) + def accept_at_in_hours(self, hours): + """set auto accept_at time""" + import datetime + + now = datetime.datetime.utcnow() + now = now + datetime.timedelta(hours=hours) + self.accept_at = now.isoformat() + @staticmethod def format_review(review, show_srcupdate=False): """