Save graph in crawl converter

This commit is contained in:
Sebastian Lohff 2020-06-14 00:24:18 +02:00
parent 53c70e8042
commit 7208502bfb
1 changed files with 8 additions and 2 deletions

View File

@ -7,7 +7,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dnmapper.settings")
import django import django
django.setup() django.setup()
from backend.crawler import convert_crawl from backend.crawler import convert_crawl, net_to_json
from bgpdata.models import CrawlRun from bgpdata.models import CrawlRun
@ -21,7 +21,13 @@ def main():
except CrawlRun.DoesNotExist: except CrawlRun.DoesNotExist:
parser.error("CrawlRun with id {} does not exist".format(args.crawl_id)) parser.error("CrawlRun with id {} does not exist".format(args.crawl_id))
convert_crawl(crawl) 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__': if __name__ == '__main__':