stagingapi: convert rebuild_broken to a generator for instant feedback.
Otherwise, the rebuild command does not print output until all the rebuilds for a whole staging are completed. With this change each package should be printed immediately.
This commit is contained in:
parent
52d356db29
commit
50f8042ba9
@ -13,5 +13,5 @@ class RebuildCommand(object):
|
|||||||
for staging in stagings:
|
for staging in stagings:
|
||||||
status = self.api.project_status(staging)
|
status = self.api.project_status(staging)
|
||||||
rebuilt = self.api.rebuild_broken(status, not force)
|
rebuilt = self.api.rebuild_broken(status, not force)
|
||||||
for key, code in rebuilt.items():
|
for key, code in rebuilt:
|
||||||
print('rebuild {} {}'.format(key, code))
|
print('rebuild {} {}'.format(key, code))
|
||||||
|
@ -801,26 +801,20 @@ class StagingAPI(object):
|
|||||||
|
|
||||||
def rebuild_broken(self, status, check=True):
|
def rebuild_broken(self, status, check=True):
|
||||||
""" Rebuild broken packages given a staging's status information. """
|
""" Rebuild broken packages given a staging's status information. """
|
||||||
rebuilt = {}
|
for project in self.project_status_walk(status):
|
||||||
for package in status['broken_packages']:
|
for package in project['broken_packages']:
|
||||||
package = {k: str(v) for k, v in package.items()}
|
package = {k: str(v) for k, v in package.items()}
|
||||||
if package['state'] == 'unresolvable':
|
if package['state'] == 'unresolvable':
|
||||||
continue
|
continue
|
||||||
key = '/'.join((package['project'], package['package'], package['repository'], package['arch']))
|
key = '/'.join((package['project'], package['package'], package['repository'], package['arch']))
|
||||||
if check and not self.rebuild_check(package['project'], package['package'],
|
if check and not self.rebuild_check(package['project'], package['package'],
|
||||||
package['repository'], package['arch']):
|
package['repository'], package['arch']):
|
||||||
rebuilt[key] = 'skipped'
|
yield (key, 'skipped')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
code = rebuild(self.apiurl, package['project'], package['package'],
|
code = rebuild(self.apiurl, package['project'], package['package'],
|
||||||
package['repository'], package['arch'])
|
package['repository'], package['arch'])
|
||||||
rebuilt[key] = code
|
yield (key, code)
|
||||||
|
|
||||||
for project in status['subprojects']:
|
|
||||||
if project:
|
|
||||||
rebuilt.update(self.rebuild_broken(project, check))
|
|
||||||
|
|
||||||
return rebuilt
|
|
||||||
|
|
||||||
def rebuild_check(self, project, package, repository, architecture):
|
def rebuild_check(self, project, package, repository, architecture):
|
||||||
history = self.job_history_get(project, repository, architecture, package)
|
history = self.job_history_get(project, repository, architecture, package)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user