Index: tools/gformat.py
===================================================================
--- tools/gformat.py	(revision 10880)
+++ tools/gformat.py	(revision 10881)
@@ -158,6 +158,8 @@
   gfile = os.path.join(NODE_DIR,item,'wleiden.yaml')
 
+  output = generate_wleiden_yaml(datadump, header)
+
   f = open(gfile, 'w')
-  f.write(generate_wleiden_yaml(datadump, header))
+  f.write(output)
   f.close()
 
@@ -930,13 +932,43 @@
   output += "\n\n"
 
-  key_order = [ 'comment', 'interface', 'ip', 'sdesc', 'mode', 'type',
-    'extra_type', 'channel', 'ssid', 'dhcp' ]
+  # Format (key, required)
+  key_order = (
+    ('comment', True),
+    ('interface', True),
+    ('ip', True),
+    ('desc', True),
+    ('sdesc', True),
+    ('mode', True),
+    ('type', True),
+    ('extra_type', False), 
+    ('channel', False),
+    ('ssid', False),
+    ('dhcp', True),
+    ('dhcpclient', False),
+    ('compass', False),
+    ('distance', False),
+    ('ns_ip', False),
+    ('bullet2_ip', False),
+    ('ns_mac', False),
+    ('bullet2_mac', False),
+    ('ns_ssid', False),
+    ('ns_type', False),
+    ('status', True),
+  )
 
   for iface_key in sorted(iface_keys):
-    output += "%s:\n" % iface_key
-    for key in key_order + list(sorted(set(datadump[iface_key].keys()) - set(key_order))):
-      if datadump[iface_key].has_key(key):
-        output += "  %-11s: %s\n" % (key, format_yaml_value(datadump[iface_key][key]))
-    output += "\n\n"
+    try:
+      remainder = set(datadump[iface_key].keys()) - set([x[0] for x in key_order])
+      if remainder:
+        raise KeyError("invalid keys: %s" % remainder)
+
+      output += "%s:\n" % iface_key
+      for key,required in key_order:
+        if datadump[iface_key].has_key(key):
+          output += "  %-11s: %s\n" % (key, format_yaml_value(datadump[iface_key][key]))
+      output += "\n\n"
+    except Exception as e:
+      print "# Error while processing interface %s" % iface_key
+      raise
 
   return output
@@ -1434,48 +1466,52 @@
 
       for host,datadump in datadumps.iteritems():
-        # Convert all yes and no to boolean values
-        def fix_boolean(dump):
-          for key in dump.keys():
-            if type(dump[key]) == dict:
-              dump[key] = fix_boolean(dump[key])
-            elif str(dump[key]).lower() in ["yes", "true"]:
-              dump[key] = True
-            elif str(dump[key]).lower() in ["no", "false"]:
-              # Compass richting no (Noord Oost) is valid input
-              if key != "compass": dump[key] = False
-          return dump
-        datadump = fix_boolean(datadump)
-
-        if datadump['rdnap_x'] and datadump['rdnap_y']:
-          datadump['latitude'], datadump['longitude'] = rdnap.rd2etrs(datadump['rdnap_x'], datadump['rdnap_y'])
-        elif datadump['latitude'] and datadump['longitude']:
-          datadump['rdnap_x'], datadump['rdnap_y'] = rdnap.etrs2rd(datadump['latitude'], datadump['longitude'])
-
-        if datadump['nodename'].startswith('Proxy'):
-          datadump['nodename'] = datadump['nodename'].lower()
-
-        for iface_key in datadump['autogen_iface_keys']:
-          # All our normal wireless cards are normal APs now
-          if datadump[iface_key]['type'] in ['11a', '11b', '11g', 'wireless']:
-            datadump[iface_key]['mode'] = 'ap'
-          # Wireless Leiden SSID have an consistent lowercase/uppercase
-          if datadump[iface_key].has_key('ssid'):
-            ssid = datadump[iface_key]['ssid']
-            prefix = 'ap-WirelessLeiden-'
-            if ssid.lower().startswith(prefix.lower()):
-              datadump[iface_key]['ssid'] = prefix + ssid[len(prefix)].upper() + ssid[len(prefix) + 1:] 
-          if datadump[iface_key].has_key('ns_ip') and not datadump[iface_key].has_key('mode'):
-            datadump[iface_key]['mode'] = 'autogen-FIXME'
-          if not datadump[iface_key].has_key('comment'):
-            datadump[iface_key]['comment'] = 'autogen-FIXME'
-          # Set the compass value based on the angle between the poels
-          if datadump[iface_key].has_key('ns_ip'):
-            my_pool = poel[network(datadump[iface_key]['ip'])]
-            remote_hosts = list(set([x[0] for x in my_pool]) - set([host]))
-            if remote_hosts:
-              compass_target = remote_hosts[0]
-              datadump[iface_key]['compass'] = cd_between_hosts(host, compass_target, datadumps)
-            
-        store_yaml(datadump)
+        try:
+          # Convert all yes and no to boolean values
+          def fix_boolean(dump):
+            for key in dump.keys():
+              if type(dump[key]) == dict:
+                dump[key] = fix_boolean(dump[key])
+              elif str(dump[key]).lower() in ["yes", "true"]:
+                dump[key] = True
+              elif str(dump[key]).lower() in ["no", "false"]:
+                # Compass richting no (Noord Oost) is valid input
+                if key != "compass": dump[key] = False
+            return dump
+          datadump = fix_boolean(datadump)
+
+          if datadump['rdnap_x'] and datadump['rdnap_y']:
+            datadump['latitude'], datadump['longitude'] = rdnap.rd2etrs(datadump['rdnap_x'], datadump['rdnap_y'])
+          elif datadump['latitude'] and datadump['longitude']:
+            datadump['rdnap_x'], datadump['rdnap_y'] = rdnap.etrs2rd(datadump['latitude'], datadump['longitude'])
+
+          if datadump['nodename'].startswith('Proxy'):
+            datadump['nodename'] = datadump['nodename'].lower()
+
+          for iface_key in datadump['autogen_iface_keys']:
+            # All our normal wireless cards are normal APs now
+            if datadump[iface_key]['type'] in ['11a', '11b', '11g', 'wireless']:
+              datadump[iface_key]['mode'] = 'ap'
+            # Wireless Leiden SSID have an consistent lowercase/uppercase
+            if datadump[iface_key].has_key('ssid'):
+              ssid = datadump[iface_key]['ssid']
+              prefix = 'ap-WirelessLeiden-'
+              if ssid.lower().startswith(prefix.lower()):
+                datadump[iface_key]['ssid'] = prefix + ssid[len(prefix)].upper() + ssid[len(prefix) + 1:] 
+            if datadump[iface_key].has_key('ns_ip') and not datadump[iface_key].has_key('mode'):
+              datadump[iface_key]['mode'] = 'autogen-FIXME'
+            if not datadump[iface_key].has_key('comment'):
+              datadump[iface_key]['comment'] = 'autogen-FIXME'
+            # Set the compass value based on the angle between the poels
+            if datadump[iface_key].has_key('ns_ip'):
+              my_pool = poel[network(datadump[iface_key]['ip'])]
+              remote_hosts = list(set([x[0] for x in my_pool]) - set([host]))
+              if remote_hosts:
+                compass_target = remote_hosts[0]
+                datadump[iface_key]['compass'] = cd_between_hosts(host, compass_target, datadumps)
+              
+          store_yaml(datadump)
+        except Exception as e:
+          print "# Error while processing %s" % host
+          raise
     elif sys.argv[1] == "list":
       use_fqdn = False
