From 93ee829260a6abf094cbbc31e26eb21bf45e8f15 Mon Sep 17 00:00:00 2001 From: Max Lin Date: Wed, 4 Jul 2018 18:09:01 +0800 Subject: [PATCH] stagingapi: remove project_status_walk() function subprojects method has been removed from dashboard, project_status_walk() is not needed anymore. --- osclib/stagingapi.py | 37 ++++++++++++++----------------------- repo_checker.py | 9 ++++----- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/osclib/stagingapi.py b/osclib/stagingapi.py index 3f02357a..429257c1 100644 --- a/osclib/stagingapi.py +++ b/osclib/stagingapi.py @@ -911,19 +911,18 @@ class StagingAPI(object): def rebuild_broken(self, status, check=True): """ Rebuild broken packages given a staging's status information. """ - for project in self.project_status_walk(status): - for package in project['broken_packages']: - package = {k: str(v) for k, v in package.items()} - if package['state'] == 'unresolvable': - continue - key = (package['project'], package['package'], - package['repository'], package['arch']) - if check and not self.rebuild_check(*key): - yield (key, 'skipped') - continue + for package in status['broken_packages']: + package = {k: str(v) for k, v in package.items()} + if package['state'] == 'unresolvable': + continue + key = (package['project'], package['package'], + package['repository'], package['arch']) + if check and not self.rebuild_check(*key): + yield (key, 'skipped') + continue - code = rebuild(self.apiurl, *key) - yield (key, code) + code = rebuild(self.apiurl, *key) + yield (key, code) def rebuild_check(self, project, package, repository, architecture): history = self.job_history_get(project, repository, architecture, package) @@ -1002,13 +1001,6 @@ class StagingAPI(object): url = self.makeurl(path, {'format': 'json'}) return json.load(self.retried_GET(url)) - def project_status_walk(self, project): - yield project - for sub in project['subprojects']: - # Oddly, dashboard returns [ None ] instead of []. - if sub is not None: - yield sub - def check_project_status(self, project): """ Checks a staging project for acceptance. Use the JSON document @@ -1027,10 +1019,9 @@ class StagingAPI(object): def project_status_build_sum(self, status): final = tobuild = 0 - for project in self.project_status_walk(status): - for repo in project['building_repositories']: - final += int(repo['final']) - tobuild += int(repo['tobuild']) + for repo in status['building_repositories']: + final += int(repo['final']) + tobuild += int(repo['tobuild']) return final, tobuild def project_status_requests(self, request_type, filter_function=None): diff --git a/repo_checker.py b/repo_checker.py index 886000c4..1a3c5c64 100755 --- a/repo_checker.py +++ b/repo_checker.py @@ -166,11 +166,10 @@ class RepoChecker(ReviewBot.ReviewBot): if status and str(status['overall_state']) == 'failed': # Exception to the rule is openQA only in failed state. openQA_only = True - for project in api.project_status_walk(status): - if len(project['broken_packages']): - # Broken packages so not just openQA. - openQA_only = False - break + if len(status['broken_packages']): + # Broken packages so not just openQA. + openQA_only = False + break if not self.force and not openQA_only: self.logger.debug('{}: {} not ready'.format(request.reqid, group))