Merge pull request #421 from lnussel/master

implement checking submit requests
This commit is contained in:
Ludwig Nussel 2015-10-05 10:32:00 +02:00
commit 8758e1a9f7
3 changed files with 62 additions and 38 deletions

View File

@ -275,6 +275,18 @@ class ReviewBot(object):
req.read(request)
self.requests.append(req)
def set_request_ids_project(self, project, typename):
url = osc.core.makeurl(self.apiurl, ('search', 'request'),
"match=(state/@name='review'+or+state/@name='new')+and+(action/target/@project='%s'+and+action/@type='%s')&withhistory=1"%(project, typename))
root = ET.parse(osc.core.http_GET(url)).getroot()
self.requests = []
for request in root.findall('request'):
req = osc.core.Request()
req.read(request)
self.requests.append(req)
class CommandLineInterface(cmdln.Cmdln):
def __init__(self, *args, **kwargs):
cmdln.Cmdln.__init__(self, args, kwargs)
@ -325,7 +337,7 @@ class CommandLineInterface(cmdln.Cmdln):
logger = self.logger)
def do_id(self, subcmd, opts, *args):
"""${cmd_name}: print the status of working copy files and directories
"""${cmd_name}: check the specified request ids
${cmd_usage}
${cmd_option_list}
@ -333,8 +345,9 @@ class CommandLineInterface(cmdln.Cmdln):
self.checker.set_request_ids(args)
self.checker.check_requests()
@cmdln.option('-n', '--interval', metavar="minutes", type="int", help="periodic interval in minutes")
def do_review(self, subcmd, opts, *args):
"""${cmd_name}: print the status of working copy files and directories
"""${cmd_name}: check requests that have the specified user or group as reviewer
${cmd_usage}
${cmd_option_list}
@ -342,8 +355,25 @@ class CommandLineInterface(cmdln.Cmdln):
if self.checker.review_user is None and self.checker.review_group is None:
raise osc.oscerr.WrongArgs("missing reviewer (user or group)")
self.checker.set_request_ids_search_review()
self.checker.check_requests()
def work():
self.checker.set_request_ids_search_review()
self.checker.check_requests()
self.runner(work, opts.interval)
@cmdln.option('-n', '--interval', metavar="minutes", type="int", help="periodic interval in minutes")
def do_project(self, subcmd, opts, project, typename):
"""${cmd_name}: check all requests of specified type to specified
${cmd_usage}
${cmd_option_list}
"""
def work():
self.checker.set_request_ids_project(project, typename)
self.checker.check_requests()
self.runner(work, opts.interval)
def runner(self, workfunc, interval):
""" runs the specified callback every <interval> minutes or

View File

@ -1055,18 +1055,6 @@ class ABIChecker(ReviewBot.ReviewBot):
return fetchlist, liblist
def set_request_ids_project(self, project, typename):
url = osc.core.makeurl(self.apiurl, ('search', 'request'),
"match=(state/@name='review'+or+state/@name='new')+and+(action/target/@project='%s'+and+action/@type='%s')&withhistory=1"%(project, typename))
root = ET.parse(osc.core.http_GET(url)).getroot()
self.requests = []
for request in root.findall('request'):
req = osc.core.Request()
req.read(request)
self.requests.append(req)
class CommandLineInterface(ReviewBot.CommandLineInterface):
def __init__(self, *args, **kwargs):
@ -1110,14 +1098,6 @@ class CommandLineInterface(ReviewBot.CommandLineInterface):
src_rev = opts.revision
print self.checker.check_source_submission(src_project, src_package, src_rev, dst_project, dst_package)
@cmdln.option('-n', '--interval', metavar="minutes", type="int", help="periodic interval in minutes")
def do_project(self, subcmd, opts, project, typename):
def work():
self.checker.set_request_ids_project(project, typename)
self.checker.check_requests()
self.runner(work, opts.interval)
if __name__ == "__main__":
app = CommandLineInterface()
sys.exit( app.main() )

View File

@ -68,7 +68,7 @@ class MaintenanceChecker(ReviewBot.ReviewBot):
url = osc.core.makeurl(self.apiurl, ('search', 'owner'), query=query)
root = ET.parse(osc.core.http_GET(url)).getroot()
package_reviews = set((r.by_project, r.by_package) for r in req.reviews if r.by_package)
package_reviews = set((r.by_project, r.by_package) for r in req.reviews if r.by_project)
for p in root.findall('./owner'):
prj = p.get("project")
pkg = p.get("package")
@ -78,21 +78,12 @@ class MaintenanceChecker(ReviewBot.ReviewBot):
self.add_review(req, by_project = prj, by_package = pkg,
msg = "Submission by someone who is not maintainer in the devel project. Please review")
def check_action_maintenance_incident(self, req, a):
known_maintainer = False
author = req.get_creator()
# check if there is a link and use that or the real package
# name as src_packge may end with something like
# .openSUSE_XX.Y_Update
pkgname = a.src_package
(linkprj, linkpkg) = self._get_linktarget(a.src_project, pkgname)
if linkpkg is not None:
pkgname = linkpkg
if pkgname == 'patchinfo':
return None
# check if pkgname was submitted by the correct maintainer. If not, set
# self.needs_maintainer_review
def _check_maintainer_review_needed(self, req, pkgname, author):
maintainers = set(self._maintainers(pkgname))
if maintainers:
known_maintainer = False
for m in maintainers:
if author == m:
self.logger.debug("%s is maintainer"%author)
@ -109,11 +100,34 @@ class MaintenanceChecker(ReviewBot.ReviewBot):
self.logger.warning("%s doesn't have maintainers"%pkgname)
self.needs_maintainer_review.add(pkgname)
def check_action_maintenance_incident(self, req, a):
author = req.get_creator()
# check if there is a link and use that or the real package
# name as src_packge may end with something like
# .openSUSE_XX.Y_Update
pkgname = a.src_package
(linkprj, linkpkg) = self._get_linktarget(a.src_project, pkgname)
if linkpkg is not None:
pkgname = linkpkg
if pkgname == 'patchinfo':
return None
self._check_maintainer_review_needed(req, pkgname, author)
if a.tgt_releaseproject == "openSUSE:Backports:SLE-12":
self.add_factory_source = True
return True
def check_action_submit(self, req, a):
author = req.get_creator()
pkgname = a.tgt_package
self._check_maintainer_review_needed(req, pkgname, author)
return True
def check_one_request(self, req):
self.add_factory_source = False
self.needs_maintainer_review = set()