Move pending_requests and get_request.
This commit is contained in:
parent
6ff892fdf2
commit
209dc8f961
@ -522,9 +522,10 @@ def _check_repo_group(self, id_, reqs, opts):
|
||||
fetched[p.request] = True
|
||||
packs.append(p)
|
||||
|
||||
for req, f in fetched.items():
|
||||
for request_id, f in fetched.items():
|
||||
if not f:
|
||||
packs.extend(self._check_repo_fetch_request(req, opts))
|
||||
request = self.checkrepo.get_request(request_id)
|
||||
packs.extend(self._check_repo_one_request(request, opts))
|
||||
for p in packs:
|
||||
if fetched[p.request]:
|
||||
continue
|
||||
@ -654,12 +655,6 @@ def _check_repo_group(self, id_, reqs, opts):
|
||||
shutil.rmtree(destdir)
|
||||
|
||||
|
||||
def _check_repo_fetch_request(self, id_, opts):
|
||||
url = makeurl(opts.apiurl, ['request', str(id_)])
|
||||
root = ET.parse(http_GET(url)).getroot()
|
||||
return self._check_repo_one_request(root, opts)
|
||||
|
||||
|
||||
@cmdln.alias('check', 'cr')
|
||||
@cmdln.option('-s', '--skip', action='store_true', help='skip review')
|
||||
def do_check_repo(self, subcmd, opts, *args):
|
||||
@ -696,18 +691,14 @@ def do_check_repo(self, subcmd, opts, *args):
|
||||
|
||||
packs = []
|
||||
if not ids:
|
||||
# xpath query, using the -m, -r, -s options
|
||||
where = "@by_user='factory-repo-checker'+and+@state='new'"
|
||||
url = makeurl(opts.apiurl, ['search', 'request'],
|
||||
"match=state/@name='review'+and+review[%s]" % where)
|
||||
f = http_GET(url)
|
||||
root = ET.parse(f).getroot()
|
||||
for rq in root.findall('request'):
|
||||
packs.extend(self._check_repo_one_request(rq, opts))
|
||||
# Return a list, we flat here with .extend()
|
||||
for request in self.checkrepo.pending_requests():
|
||||
packs.extend(self._check_repo_one_request(request, opts))
|
||||
else:
|
||||
# we have a list, use them.
|
||||
for id_ in ids:
|
||||
packs.extend(self._check_repo_fetch_request(id_, opts))
|
||||
for request_id in ids:
|
||||
request = self.checkrepo.get_request(request_id)
|
||||
packs.extend(self._check_repo_one_request(request, opts))
|
||||
|
||||
# Order the packs before grouping
|
||||
packs = sorted(packs, key=lambda p: p.request, reverse=True)
|
||||
|
@ -17,6 +17,7 @@
|
||||
import urllib2
|
||||
from xml.etree import cElementTree as ET
|
||||
|
||||
from osc.core import http_GET
|
||||
from osc.core import http_POST
|
||||
from osc.core import makeurl
|
||||
|
||||
@ -73,3 +74,26 @@ class CheckRepo(object):
|
||||
except urllib2.HTTPError, e:
|
||||
print('ERROR in URL %s [%s]' % (url, e))
|
||||
return code
|
||||
|
||||
def get_request(self, request_id):
|
||||
"""Get a request XML onject."""
|
||||
request = None
|
||||
try:
|
||||
url = makeurl(self.apiurl, ('request', str(request_id)))
|
||||
request = ET.parse(http_GET(url)).getroot()
|
||||
except urllib2.HTTPError, e:
|
||||
print('ERROR in URL %s [%s]' % (url, e))
|
||||
return request
|
||||
|
||||
def pending_requests(self):
|
||||
"""Search pending requests to review."""
|
||||
requests = []
|
||||
where = "@by_user='factory-repo-checker'+and+@state='new'"
|
||||
try:
|
||||
url = makeurl(self.apiurl, ('search', 'request'),
|
||||
"match=state/@name='review'+and+review[%s]" % where)
|
||||
root = ET.parse(http_GET(url)).getroot()
|
||||
requests = root.findall('request')
|
||||
except urllib2.HTTPError, e:
|
||||
print('ERROR in URL %s [%s]' % (url, e))
|
||||
return requests
|
||||
|
Loading…
x
Reference in New Issue
Block a user