setprio: utilize project_status() and refactor to support list of stagings.
The existing setup was inconsistent in that it was copied from check, but documented that it supported multiple specific stagings. Assuming that would be a desired feature anyway it has been reworked.
This commit is contained in:
parent
331ec53e72
commit
84e1b66cd8
@ -252,7 +252,7 @@ def do_staging(self, subcmd, opts, *args):
|
|||||||
elif cmd == 'frozenage':
|
elif cmd == 'frozenage':
|
||||||
min_args, max_args = 0, None
|
min_args, max_args = 0, None
|
||||||
elif cmd == 'setprio':
|
elif cmd == 'setprio':
|
||||||
min_args, max_args = 0, 1
|
min_args, max_args = 0, None
|
||||||
elif cmd == 'check':
|
elif cmd == 'check':
|
||||||
min_args, max_args = 0, 1
|
min_args, max_args = 0, 1
|
||||||
elif cmd == 'select':
|
elif cmd == 'select':
|
||||||
|
@ -48,24 +48,21 @@ class PrioCommand(object):
|
|||||||
print e
|
print e
|
||||||
|
|
||||||
|
|
||||||
def perform(self, project=None):
|
def perform(self, projects=None):
|
||||||
"""
|
"""
|
||||||
Check one staging project verbosibly or all of them at once
|
Set priority on specific stagings or all of them at once
|
||||||
:param project: project to check, None for all
|
:param projects: projects on which to set priority, None for all
|
||||||
"""
|
"""
|
||||||
|
|
||||||
query = {'format': 'json'}
|
aggregate = False
|
||||||
path = [ 'project', 'staging_projects', self.api.project ]
|
if not projects:
|
||||||
if project:
|
aggregate = True
|
||||||
path += project
|
projects = self.api.get_staging_projects()
|
||||||
url = self.api.makeurl(path, query=query)
|
|
||||||
info = json.load(self.api.retried_GET(url))
|
for project in projects:
|
||||||
if not project:
|
info = self.api.project_status(project, aggregate)
|
||||||
for prj in info:
|
if not info['selected_requests']:
|
||||||
if not prj['selected_requests']:
|
continue
|
||||||
continue
|
|
||||||
self._setprio(prj)
|
|
||||||
else:
|
|
||||||
self._setprio(info)
|
self._setprio(info)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user