Browse Source

handle errornous data better

Helge Jung 8 years ago
parent
commit
1a13988363
2 changed files with 4 additions and 2 deletions
  1. 2 0
      ffstatus/basestorage.py
  2. 2 2
      ffstatus/server.py

+ 2 - 0
ffstatus/basestorage.py

@@ -15,6 +15,8 @@ def sanitize_node(data, include_raw_data=False):
     Filters potentially harmful entries from the node's data.
     """
     export = ffstatus.dict_merge({}, data)
+    if export is None:
+        return {}
 
     # remove fields from output: __RAW__
     if '__RAW__' in export and not include_raw_data:

+ 2 - 2
ffstatus/server.py

@@ -556,10 +556,10 @@ angesprochen und sollte aus einer Mehrzahl von Gründen nicht
 
             for nodeid in nodes:
                 node = nodes[nodeid]
-                nodename = node.get('hostname', '?')
+                nodename = node.get('hostname') or '?'
                 nodeinfo = 'node "%s" (id %s)' % (nodename.decode('utf-8'), nodeid)
 
-                if ident == node.get('mac', '').lower():
+                if ident == (node.get('mac') or '').lower():
                     answer.append('primary mac of ' + nodeinfo)
                 elif ident in [x.lower() for x in node.get('macs', [])]:
                     answer.append('mac of ' + nodeinfo)