Distinct copyrights were left as I do not wish to track down commit history to ensure it properly documents the copyright holders. Also left non-GPLv2 licenses and left bs_copy untouched as a mirror from OBS. Already have a mix of with and without headers and even OBS does not place on majority of files. If SUSE lawyers have an issue it will come up in legal review for Factory.
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
import json
|
|
import osc
|
|
import urllib2
|
|
|
|
class PrioCommand(object):
|
|
def __init__(self, api):
|
|
self.api = api
|
|
|
|
def _setprio(self, project, priority):
|
|
"""
|
|
Set prios for requests that are still in review
|
|
:param project: project to check
|
|
|
|
"""
|
|
|
|
# XXX taking name verbatim would produce null byte error
|
|
# https://github.com/openSUSE/open-build-service/issues/2493
|
|
message = 'raising priority for %s'%str(project['name'])
|
|
for r in project['missing_reviews']:
|
|
reqid = str(r['request'])
|
|
req = osc.core.get_request(self.api.apiurl, reqid)
|
|
if req.priority != priority:
|
|
query = { 'cmd': 'setpriority', 'priority': priority }
|
|
url = osc.core.makeurl(self.api.apiurl, ['request', reqid], query)
|
|
print reqid, message
|
|
try:
|
|
osc.core.http_POST(url, data=message)
|
|
print reqid, r['by'], priority
|
|
except urllib2.HTTPError as e:
|
|
print e
|
|
|
|
|
|
def perform(self, projects=None, priority=None):
|
|
"""
|
|
Set priority on specific stagings or all of them at once
|
|
:param projects: projects on which to set priority, None for all
|
|
"""
|
|
|
|
aggregate = False
|
|
if not projects:
|
|
aggregate = True
|
|
projects = self.api.get_staging_projects()
|
|
|
|
if not priority:
|
|
priority = 'important'
|
|
|
|
for project in projects:
|
|
info = self.api.project_status(project, aggregate)
|
|
if not info['selected_requests']:
|
|
continue
|
|
self._setprio(info, priority)
|
|
|
|
return True
|