def main(): def deleteTestLogs(prList): logger = logging.getLogger("prLogClenUpMethod") for pr in prList: try: bash("rm -rf /mnt/test_result_archive/%s" % (pr["build_number"])) except KeyError as e: logger.error("keyError occured, no key named %s for prNo %s" % (e.args[0], pr["pr_no"])) gc = garbageCollector() j = jenKinsJob() resourceMgr = resourceManager() gc.garbageCollect(resourceMgr.getJobDetails(), "created", j.deleteJob) gc.setCollectAfterDays(2) g = gitDb() gc.garbageCollect(g.getTestedPrs(), "updated_at", deleteTestLogs)
def needsTesting(prToTest): avoidList = ["ui", "vmware", "checkstyle", "logrotate", "kvm", "automation", "automated"] titleWords = [word.lower() for word in prToTest["pr_name"].split()] for word in titleWords: if word in avoidList: return False return True if inp_dict["mailto"] == None: logging.info("no email id specified.") sys.exit(1) g = gitDb() if inp_dict["buildFromPr"] == "None": prToTest = None while True: prToTest = g.getPrToTest() if (prToTest is not None) and (not needsTesting(prToTest)): logging.info("pr %s title %s needs no testing" % (prToTest["pr_no"], prToTest["pr_name"])) prToTest["tested"] = "NA" g.updatePr(prToTest) prToTest = None else: break else: pr = inp_dict["buildFromPr"] pr = pr.split(":") prToTest = g.findPrByNumber(pr[0], pr[1])