Browse Source

Save graph in crawl converter

Sebastian Lohff 1 year ago
parent
commit
7208502bfb
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      bin/conv.py

+ 8
- 2
bin/conv.py View File

@@ -7,7 +7,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dnmapper.settings")
7 7
 import django
8 8
 django.setup()
9 9
 
10
-from backend.crawler import convert_crawl
10
+from backend.crawler import convert_crawl, net_to_json
11 11
 from bgpdata.models import CrawlRun
12 12
 
13 13
 
@@ -21,7 +21,13 @@ def main():
21 21
     except CrawlRun.DoesNotExist:
22 22
         parser.error("CrawlRun with id {} does not exist".format(args.crawl_id))
23 23
 
24
-    convert_crawl(crawl)
24
+    net = convert_crawl(crawl)
25
+    if net.nodes and net.edges:
26
+        crawl.graph = net_to_json(net)
27
+        crawl.save()
28
+        print("Crawl updated")
29
+    else:
30
+        print("Crawl had no nodes or edges, abort")
25 31
 
26 32
 
27 33
 if __name__ == '__main__':

Loading…
Cancel
Save