Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 2 files changed
  • 0 comments
  • 1 contributor
25  Discoverer.py
@@ -6,6 +6,7 @@
6 6
 discoverers.
7 7
 """
8 8
 
  9
+import logging
9 10
 import os
10 11
 
11 12
 from glob      import glob
@@ -71,8 +72,13 @@ def getAllDiscoverers():
71 72
 
72 73
     for name in glob('{base}/Discoverer_*.py'.format(base=basepath)):
73 74
         modname = os.path.splitext(os.path.split(name)[1])[0]
74  
-        module  = __import__('{mod}'.format(mod=modname))
75  
-        classes.append(getattr(module, modname))
  75
+        try:
  76
+            module  = __import__('{mod}'.format(mod=modname))
  77
+            classes.append(getattr(module, modname))
  78
+        except Exception as e:
  79
+            # Don't crash on someone else's behalf.
  80
+            logging.error(e)
  81
+            continue
76 82
 
77 83
     return classes
78 84
 
@@ -88,9 +94,16 @@ def startDiscovery(output, intrusive=False):
88 94
     """
89 95
     classes    = filter(lambda d: intrusive or not d.isIntrusive,
90 96
                         getAllDiscoverers())
91  
-    instances  = [klass(output) for klass in classes]
92  
-
93  
-    for discoverer in instances:
94  
-        discoverer.start()
  97
+    instances  = []
  98
+
  99
+    for klass in classes:
  100
+        try:
  101
+            instance = klass(output)
  102
+            instances.append(instance)
  103
+            instance.start()
  104
+        except Exception as e:
  105
+            # Don't crash because someone didn't read the docs
  106
+            logging.error(e)
  107
+            continue
95 108
 
96 109
     return instances
10  Discoverer_Arp.py
@@ -28,10 +28,12 @@ def runOnce(self):
28 28
             if tokens[1] != 1 or not tokens[2] & 2:
29 29
                 continue
30 30
 
31  
-            out = {'device':
32  
-                      {'ipv4.address': tokens[0],
33  
-                       'eth.address' : tokens[3],
34  
-                       'if.name'     : tokens[5]}}
  31
+            out = {'devices':
  32
+                      [{'ipv4': {'address'  : tokens[0]},
  33
+                        'eth' : {'address'  : tokens[3],
  34
+                                 'interface': tokens[5]}}],
  35
+                   'interfaces': [{'name':tokens[5]}] }
  36
+
35 37
             self.output.put(out)
36 38
 
37 39
         input.close()

No commit comments for this range

Something went wrong with that request. Please try again.