Add post-parse site hooks (parse -P to trigger, default = off)
Make scheduler call tko/parse with -P

Signed-off-by: Rachel Kroll <rkroll@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@3123 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/tko/parse.py b/tko/parse.py
index 40cb77f..a832a36 100755
--- a/tko/parse.py
+++ b/tko/parse.py
@@ -5,6 +5,7 @@
 import common
 from autotest_lib.client.common_lib import mail, pidfile
 from autotest_lib.tko import db as tko_db, utils as tko_utils, status_lib, models
+from autotest_lib.client.common_lib import utils
 
 
 def parse_args():
@@ -29,6 +30,8 @@
                       action="store")
     parser.add_option("-d", help="Database name", dest="db_name",
                       action="store")
+    parser.add_option("-P", help="Run site post-processing",
+                      dest="site_do_post", action="store_true", default=False)
     parser.add_option("--write-pidfile",
                       help="write pidfile (.parser_execute)",
                       dest="write_pidfile", action="store_true",
@@ -230,6 +233,10 @@
         parse_leaf_path(db, path, level, reparse, mail_on_failure)
 
 
+def _site_post_parse_job_dummy():
+    return {}
+
+
 def main():
     options, args = parse_args()
     results_dir = os.path.abspath(args[0])
@@ -240,6 +247,10 @@
     if options.write_pidfile:
         pid_file_manager.open_file()
 
+    site_post_parse_job = utils.import_site_function(__file__,
+        "autotest_lib.tko.site_parse", "site_post_parse_job",
+        _site_post_parse_job_dummy)
+
     try:
         # build up the list of job dirs to parse
         if options.singledir:
@@ -271,6 +282,10 @@
             try:
                 parse_path(db, path, options.level, options.reparse,
                            options.mailit)
+
+                if options.site_do_post is True:
+                    site_post_parse_job(path)
+
             finally:
                 fcntl.flock(lockfile, fcntl.LOCK_UN)
                 lockfile.close()