From b91cc995ddc1d32d747ef59b84099bc13ffd4eb3 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Fri, 8 Nov 2019 11:31:23 +0100 Subject: [PATCH] Fixes for adi command --- osclib/adi_command.py | 56 ++++++++++++++++++++++++----------------- osclib/stagingapi.py | 34 ------------------------- staging-installcheck.py | 2 +- 3 files changed, 34 insertions(+), 58 deletions(-) diff --git a/osclib/adi_command.py b/osclib/adi_command.py index 33df5588..30a96bd9 100644 --- a/osclib/adi_command.py +++ b/osclib/adi_command.py @@ -22,45 +22,52 @@ class AdiCommand: def check_adi_project(self, project): query_project = self.api.extract_staging_short(project) - info = self.api.project_status(project, True) + info = self.api.project_status(project, reload=True) - if info.find('selected_requests/entry') is not None: + if info.find('staged_requests/request') is not None: if info.find('building_repositories/entry') is not None: print(query_project + ' ' + Fore.MAGENTA + 'building') return - if len(info['untracked_requests']): + if info.find('untracked_requests/request') is not None: print(query_project + ' ' + Fore.YELLOW + 'untracked: ' + ', '.join(['{}[{}]'.format( - Fore.CYAN + req['package'] + Fore.RESET, req['number']) for req in info['untracked_requests']])) + Fore.CYAN + req['package'] + Fore.RESET, req['number']) for req in info.findall('untracked_requests/request')])) return - if len(info['obsolete_requests']): + if info.find('obsolete_requests/request') is not None: print(query_project + ' ' + Fore.YELLOW + 'obsolete: ' + ', '.join(['{}[{}]'.format( - Fore.CYAN + req['package'] + Fore.RESET, req['number']) for req in info['obsolete_requests']])) + Fore.CYAN + req['package'] + Fore.RESET, req['number']) for req in info.findall('obsolete_requests/request')])) return - if len(info['broken_packages']): + if info.find('broken_packages/package') is not None: print(query_project + ' ' + Fore.RED + 'broken: ' + ', '.join([ - Fore.CYAN + p['package'] + Fore.RESET for p in info['broken_packages']])) + Fore.CYAN + p.get('package') + Fore.RESET for p in info.findall('broken_packages/package')])) return - for review in info['missing_reviews']: + for review in info.findall('missing_reviews/review'): print(query_project + ' ' + Fore.WHITE + 'review: ' + '{} for {}[{}]'.format( - Fore.YELLOW + review['by'] + Fore.RESET, - Fore.CYAN + review['package'] + Fore.RESET, - review['request'])) + Fore.YELLOW + review.get('by', 'https://github.com/openSUSE/open-build-service/issues/8575') + Fore.RESET, + Fore.CYAN + review.get('package') + Fore.RESET, + review.get('id', 'https://github.com/openSUSE/open-build-service/issues/8575'))) return - for check in info['missing_checks']: - print(query_project + ' ' + Fore.MAGENTA + 'missing: {}'.format(check)) + for check in info.findall('missing_checks/check'): + print(query_project + ' ' + Fore.MAGENTA + 'missing: {}'.format(check.get('name'))) return - for check in info['checks']: - if check['state'] != 'success': - print(query_project + '{} {} check: {}'.format(Fore.MAGENTA, check['state'], check['name'])) + for check in info.findall('checks/check'): + state = check.find('state').text + if state != 'success': + print(query_project + '{} {} check: {}'.format(Fore.MAGENTA, state, check.get('name').text)) return + overall_state = info.get('state') + if overall_state != 'acceptable' and overall_state != 'empty': + raise oscerr.WrongArgs('Missed some case') + if self.api.is_user_member_of(self.api.user, self.api.cstaging_group): print(query_project + ' ' + Fore.GREEN + 'ready') packages = [] - for req in info['selected_requests']: - print(' - {} [{}]'.format(Fore.CYAN + req['package'] + Fore.RESET, req['number'])) - self.api.rm_from_prj(project, request_id=req['number'], msg='ready to accept') - packages.append(req['package']) + for req in info.findall('staged_requests/request'): + msg = 'ready to accept' + print(' - {} [{}]'.format(Fore.CYAN + req.get('package') + Fore.RESET, req.get('id'))) + self.api.rm_from_prj(project, request_id=req.get('id'), msg=msg) + self.api.do_change_review_state(req.get('id'), 'accepted', by_group=self.api.cstaging_group, message=msg) + packages.append(req.get('package')) self.api.accept_status_comment(project, packages) try: delete_project(self.api.apiurl, project, force=True) @@ -68,8 +75,11 @@ class AdiCommand: print(e) pass else: - print(query_project, Fore.GREEN + 'ready:', ', '.join(['{}[{}]'.format( - Fore.CYAN + req['package'] + Fore.RESET, req['number']) for req in info['selected_requests']])) + ready=[] + for req in info.findall('staged_requests/request'): + ready.append('{}[{}]'.format(Fore.CYAN + req.get('package') + Fore.RESET, req.get('id'))) + if len(ready): + print(query_project, Fore.GREEN + 'ready:', ', '.join(ready)) def check_adi_projects(self): for p in self.api.get_adi_projects(): diff --git a/osclib/stagingapi.py b/osclib/stagingapi.py index f9b5784b..8fbf8747 100644 --- a/osclib/stagingapi.py +++ b/osclib/stagingapi.py @@ -402,40 +402,6 @@ class StagingAPI(object): return False - def accept_non_ring_request(self, request): - """ - Accept review of requests that are not yet in any ring so we - don't delay their testing. - :param request: request to check - """ - - # Consolidate all data from request - request_id = int(request.get('id')) - action = request.findall('action') - if not action: - msg = 'Request {} has no action'.format(request_id) - raise oscerr.WrongArgs(msg) - # we care only about first action - action = action[0] - - # Where are we targeting the package - target_project = action.find('target').get('project') - target_package = action.find('target').get('package') - - # If the values are empty it is no error - if not target_project or not target_package: - msg = 'no target/package in request {}, action {}; ' - msg = msg.format(request_id, action) - logging.info(msg) - - # Verify the package ring - ring = self.ring_packages.get(target_package, None) - if not ring: - # accept the request here - message = 'No need for staging, not in tested ring projects.' - self.do_change_review_state(request_id, 'accepted', message=message, - by_group=self.cstaging_group) - @memoize(session=True) def source_info(self, project, package, rev=None): query = {'view': 'info'} diff --git a/staging-installcheck.py b/staging-installcheck.py index 2f961dc0..8a992a00 100755 --- a/staging-installcheck.py +++ b/staging-installcheck.py @@ -162,7 +162,7 @@ class InstallChecker(object): self.logger.error('no project status for {}'.format(project)) return False - for req in status.findall('selected_requests/entry'): + for req in status.findall('staged_requests/request'): if req.get('type') == 'delete': result = result and self.check_delete_request(req, to_ignore, result_comment)