if (not Configuration.includesFeed(source["name"]) and source["name"] != "redis-cache-cpe"): continue if args.f and source["name"] != "redis-cache-cpe": logger.info("Dropping collection: " + source["name"]) dropcollection(collection=source["name"]) logger.info(source["name"] + " dropped") if source["name"] == "cpeother": if "cpeother" not in getTableNames(): continue if source["name"] != "redis-cache-cpe": logger.info("Starting " + source["name"]) before = nbelement(collection=source["name"]) if args.f and source["name"] == "cpe": cpd = CPEDownloads() cpd.populate() elif args.f and source["name"] == "cve": cvd = CVEDownloads() cvd.populate() else: if isinstance(source["updater"], str): subprocess.Popen((shlex.split(source["updater"]))).wait() else: up = source["updater"]() up.update()
description="populate/update the local CPE database" ) argparser.add_argument("-u", action="store_true", help="update the database") argparser.add_argument("-p", action="store_true", help="populate the database") argparser.add_argument( "-a", action="store_true", default=False, help="force populating the CPE database" ) argparser.add_argument( "-f", action="store_true", default=False, help="force update of the CPE database" ) argparser.add_argument("-v", action="store_true", help="verbose output") args = argparser.parse_args() if __name__ == "__main__": cpd = CPEDownloads() cpd.logger.debug("{}".format(" ".join(sys.argv))) if args.u: last_modified = cpd.update() elif args.p: c = getSize(cpd.feed_type.lower()) if args.v: cpd.logger.info(str(c)) if c > 0 and args.a is False: cpd.logger.info("Database already populated") else: last_modified = cpd.populate()