2018-11-05 15:46:50 +01:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2017-04-21 17:09:17 -05:00
|
|
|
from colorama import Fore
|
2017-01-13 01:16:05 -06:00
|
|
|
from osclib.request_splitter import RequestSplitter
|
2017-04-19 17:11:46 -05:00
|
|
|
from osclib.supersede_command import SupersedeCommand
|
2014-02-28 11:45:06 +01:00
|
|
|
|
2022-02-18 17:15:48 +01:00
|
|
|
|
2014-02-18 14:05:57 +01:00
|
|
|
class ListCommand:
|
2017-01-13 01:16:05 -06:00
|
|
|
SOURCE_PROJECT_STRIP = [
|
|
|
|
'SUSE:SLE-12:',
|
|
|
|
'SUSE:SLE-12-',
|
|
|
|
'openSUSE:Leap:'
|
|
|
|
'openSUSE:',
|
2017-08-31 16:13:02 -05:00
|
|
|
'openSUSE.org:',
|
2017-01-13 01:16:05 -06:00
|
|
|
'home:',
|
|
|
|
]
|
|
|
|
|
2014-02-18 14:05:57 +01:00
|
|
|
def __init__(self, api):
|
|
|
|
self.api = api
|
|
|
|
|
2017-04-19 17:11:46 -05:00
|
|
|
def perform(self, supersede=False):
|
2014-03-05 13:01:55 +01:00
|
|
|
"""
|
|
|
|
Perform the list command
|
|
|
|
"""
|
2014-02-18 14:05:57 +01:00
|
|
|
|
2015-10-01 19:09:15 +08:00
|
|
|
if supersede:
|
2017-04-19 17:11:46 -05:00
|
|
|
SupersedeCommand(self.api).perform()
|
2014-03-06 11:43:21 +01:00
|
|
|
|
|
|
|
requests = self.api.get_open_requests()
|
2022-02-18 13:42:57 +01:00
|
|
|
if not len(requests):
|
|
|
|
return
|
2014-03-06 11:43:21 +01:00
|
|
|
|
2017-01-13 01:16:05 -06:00
|
|
|
splitter = RequestSplitter(self.api, requests, in_ring=True)
|
2017-01-31 18:36:54 -06:00
|
|
|
splitter.group_by('./action/target/@devel_project')
|
2017-01-13 01:16:05 -06:00
|
|
|
splitter.split()
|
|
|
|
|
2017-08-31 15:48:14 -05:00
|
|
|
hide_source = self.api.project == 'openSUSE:Factory'
|
2017-01-13 01:16:05 -06:00
|
|
|
for group in sorted(splitter.grouped.keys()):
|
2018-11-05 15:46:50 +01:00
|
|
|
print(Fore.YELLOW + group)
|
2017-01-13 01:16:05 -06:00
|
|
|
|
|
|
|
for request in splitter.grouped[group]['requests']:
|
|
|
|
request_id = int(request.get('id'))
|
|
|
|
action = request.find('action')
|
|
|
|
target_package = action.find('target').get('package')
|
|
|
|
ring = action.find('target').get('ring')
|
2017-05-10 15:56:57 -05:00
|
|
|
ring_color = Fore.MAGENTA if ring.startswith('0') else ''
|
2017-01-13 01:16:05 -06:00
|
|
|
|
2017-05-10 15:56:57 -05:00
|
|
|
line = '{} {}{:<30}{} -> {}{:<12}{}'.format(
|
|
|
|
request_id, Fore.CYAN, target_package, Fore.RESET,
|
|
|
|
ring_color, ring, Fore.RESET)
|
2017-01-13 01:16:05 -06:00
|
|
|
|
2022-02-18 15:56:45 +01:00
|
|
|
if not hide_source and action.find('source') is not None:
|
2017-01-13 01:16:05 -06:00
|
|
|
source_project = action.find('source').get('project')
|
|
|
|
source_project = self.project_strip(source_project)
|
2017-04-28 10:18:39 -05:00
|
|
|
line += ' ({})'.format(Fore.YELLOW + source_project + Fore.RESET)
|
2017-04-26 10:27:10 -05:00
|
|
|
if action.get('type') == 'delete':
|
2017-06-14 22:07:04 -05:00
|
|
|
line += ' (' + Fore.RED + 'delete request' + Fore.RESET + ')'
|
2017-01-13 01:16:05 -06:00
|
|
|
|
2017-04-28 10:18:14 -05:00
|
|
|
message = self.api.ignore_format(request_id)
|
|
|
|
if message:
|
|
|
|
line += '\n' + Fore.WHITE + message + Fore.RESET
|
2017-01-13 01:16:05 -06:00
|
|
|
|
2019-02-07 10:28:26 -06:00
|
|
|
print(' ', line)
|
2015-07-16 12:21:15 +02:00
|
|
|
|
2017-01-13 01:16:05 -06:00
|
|
|
if len(splitter.other):
|
|
|
|
non_ring_packages = []
|
|
|
|
for request in splitter.other:
|
|
|
|
non_ring_packages.append(request.find('./action/target').get('package'))
|
2018-11-05 15:46:50 +01:00
|
|
|
print('Not in a ring: ' + ' '.join(sorted(non_ring_packages)))
|
2016-06-02 16:44:29 +02:00
|
|
|
|
2017-08-31 16:18:40 -05:00
|
|
|
# Print requests not handled by staging process to highlight them.
|
2018-10-31 16:24:16 -05:00
|
|
|
splitter.stageable = False
|
2017-08-31 16:18:40 -05:00
|
|
|
for request_type in ('change_devel', 'set_bugowner'):
|
|
|
|
splitter.reset()
|
|
|
|
splitter.filter_add('./action[@type="{}"]'.format(request_type))
|
|
|
|
requests = splitter.filter_only()
|
|
|
|
if len(requests):
|
|
|
|
print('\n{} request(s)'.format(request_type))
|
|
|
|
for request in sorted(requests, key=lambda s: s.get('id')):
|
|
|
|
print(' {} {}'.format(
|
|
|
|
self.api.makeurl(['request', 'show', request.get('id')]),
|
|
|
|
request.find('./action/target').get('package')))
|
2017-01-13 01:16:05 -06:00
|
|
|
|
|
|
|
def project_strip(self, source_project):
|
|
|
|
home = source_project.startswith('home:')
|
|
|
|
|
|
|
|
for prefix in self.SOURCE_PROJECT_STRIP:
|
|
|
|
if source_project.startswith(prefix):
|
|
|
|
source_project = source_project[len(prefix):]
|
|
|
|
|
|
|
|
if home:
|
|
|
|
source_project = '~' + source_project
|
|
|
|
|
|
|
|
return source_project
|