From efbcd75064342040aa3aa4f4ddd3945a4b77ce04 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Tue, 29 Sep 2015 08:44:04 +0200 Subject: [PATCH] move check by project function to ReviewBot --- ReviewBot.py | 38 ++++++++++++++++++++++++++++++++++---- abichecker/abichecker.py | 20 -------------------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/ReviewBot.py b/ReviewBot.py index 944e0ab7..b9a1df23 100644 --- a/ReviewBot.py +++ b/ReviewBot.py @@ -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 minutes or diff --git a/abichecker/abichecker.py b/abichecker/abichecker.py index 2717c256..42726d7f 100755 --- a/abichecker/abichecker.py +++ b/abichecker/abichecker.py @@ -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() )