openSUSE-release-tools/osc-vdelreq.py
Jimmy Berry 6069245350 Remove SUSE copyright, warranty, and license headers.
Distinct copyrights were left as I do not wish to track down commit
history to ensure it properly documents the copyright holders. Also left
non-GPLv2 licenses and left bs_copy untouched as a mirror from OBS.

Already have a mix of with and without headers and even OBS does not place
on majority of files. If SUSE lawyers have an issue it will come up in
legal review for Factory.
2018-08-23 19:18:06 -05:00

84 lines
3.1 KiB
Python

#!/usr/bin/python
from __future__ import print_function
import os
import os.path
import sys
from xml.etree import cElementTree as ET
import osc.core
import osc.conf
from osc import cmdln
from osc import oscerr
def _has_binary(self, project, package):
query = {'view': 'binarylist', 'package': package, 'multibuild': '1'}
pkg_binarylist = ET.parse(osc.core.http_GET(osc.core.makeurl(self.apiurl, ['build', project, '_result'], query=query))).getroot()
for binary in pkg_binarylist.findall('./result/binarylist/binary'):
return 'Yes'
return 'No'
def list_virtually_accepted_request(self, project, opts):
state_cond = "state/@name='review'+or+state/@name='revoked'+or+state/@name='revoked'"
if opts.all:
state_cond += "+or+state/@name='accepted'"
query = "match=({})+and+(action/target/@project='{}'+and+action/@type='delete')+and+"\
"((review/@state='new'+or+review/@state='accepted')+and+review/@by_group='{}')".format(state_cond, project, opts.delreq_review)
url = osc.core.makeurl(self.apiurl, ['search', 'request'], query)
f = osc.core.http_GET(url)
root = ET.parse(f).getroot()
rqs = []
for rq in root.findall('request'):
has_binary = 'No'
id = rq.attrib['id']
rq_state = rq.find('state').get('name')
pkg = rq.find('action/target').get('package')
if rq_state != 'accepted':
has_binary = self._has_binary(project, pkg)
for review in rq.findall('review'):
if review.get('by_group') and review.attrib['by_group'] == opts.delreq_review:
delreq_review_state = review.attrib['state']
content = {"id": int(id), "package": pkg, "rq_state": rq_state, "delreq_review_state": delreq_review_state, "has_binary": has_binary}
rqs.append(content)
rqs.sort(key=lambda d: d['id'])
for rq in rqs:
print("{} {} state is {} \n {} Virtually accept review is {} ( binary: {} )".format(str(rq['id']),
rq['package'], rq['rq_state'], "-".rjust(len(str(rq['id']))+1, ' '), rq['delreq_review_state'], rq['has_binary']))
@cmdln.option('--delreq-review', dest='delreq_review', metavar='DELREQREVIEW', default='factory-maintainers',
help='the additional reviews')
@cmdln.option('--all', action='store_true', default=False, help='shows all requests including accepted request')
def do_vdelreq(self, subcmd, opts, *args):
"""${cmd_name}: display pending virtual accept delete request
osc vdelreq [OPT] COMMAND PROJECT
Shows pending the virtual accept delete requests and the current state.
${cmd_option_list}
"list" will list virtually accepted delete request.
Usage:
osc vdelreq [--delreq-review DELREQREVIEW] list PROJECT
"""
self.apiurl = self.get_api_url()
if len(args) == 0:
raise oscerr.WrongArgs('No command given, see "osc help vdelreq"!')
if len(args) < 2:
raise oscerr.WrongArgs('No project given, see "osc help vdelreq"!')
cmd = args[0]
if cmd in ('list'):
self.list_virtually_accepted_request(args[1], opts)
else:
raise oscerr.WrongArgs('Unknown command: %s' % cmd)