35 lines
846 B
Python
Executable File
35 lines
846 B
Python
Executable File
#!/usr/bin/env python
|
|
import argparse
|
|
import os
|
|
import sys
|
|
sys.path.append("..")
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dnmapper.settings")
|
|
import django
|
|
django.setup()
|
|
|
|
from backend.crawler import convert_crawl, net_to_json
|
|
from bgpdata.models import CrawlRun
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("-c", "--crawl-id", type=int)
|
|
args = parser.parse_args()
|
|
|
|
try:
|
|
crawl = CrawlRun.objects.get(pk=args.crawl_id)
|
|
except CrawlRun.DoesNotExist:
|
|
parser.error("CrawlRun with id {} does not exist".format(args.crawl_id))
|
|
|
|
net = convert_crawl(crawl)
|
|
if net.nodes and net.edges:
|
|
crawl.graph = net_to_json(net)
|
|
crawl.save()
|
|
print("Crawl updated")
|
|
else:
|
|
print("Crawl had no nodes or edges, abort")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|