f = Configuration.getFile(capecurl)
except:
sys.exit("Cannot open url %s. Bad URL or not connected to the internet?"%(capecurl))
i = info.find_one({"db": "capec"})
if i is not None:
if f.headers["last-modified"] == i["last-modified"]:
print("Not modified")
sys.exit(0)
// parse xml and store in database
parser.parse(f)
bulk = capec.initialize_ordered_bulk_op()
for attack in progressbar(ch.capec):
bulk.find({"id": attack["id"]}).upsert().update({"$set": {"name": attack["name"], "summary": attack["summary"], "prerequisites": attack["prerequisites"], "solutions": attack["solutions"], "related_weakness": attack["related_weakness"]}})
bulk.execute()
//update database info after successful program-run
info.update({"db": "capec"}, {"$set": {"last-modified": f.headers["last-modified"]}}, upsert=True)
After Change
f = Configuration.getFile(capecurl)
except:
sys.exit("Cannot open url %s. Bad URL or not connected to the internet?"%(capecurl))
i = dbLayer.getLastModified("capec")
if i is not None:
if f.headers["last-modified"] == i:
print("Not modified")
sys.exit(0)