|
@@ -55,35 +55,27 @@ def ffpb_peerinfo(bot, trigger):
|
|
|
return
|
|
|
|
|
|
# read node information
|
|
|
- info_mac = node['network']['mac'] if 'network' in node and 'mac' in node['network'] else '??:??:??:??:??:??'
|
|
|
- info_id = node['node_id'] if 'node_id' in node else info_mac.replace(':', '')
|
|
|
- info_name = node['hostname'] if 'hostname' in node else '?-' + info_id
|
|
|
+ info_mac = node.get('network', {}).get('mac', '??:??:??:??:??:??')
|
|
|
+ info_id = node.get('node_id', info_mac.replace(':', ''))
|
|
|
+ info_name = node.get('hostname', '?-' + info_id)
|
|
|
|
|
|
info_hw = ""
|
|
|
if "hardware" in node:
|
|
|
- if "model" in node["hardware"]:
|
|
|
- model = node["hardware"]["model"]
|
|
|
- info_hw = " model='" + model + "'"
|
|
|
+ model = node["hardware"]
|
|
|
+ info_hw = " model='" + model + "'"
|
|
|
|
|
|
info_fw = ""
|
|
|
info_update = ""
|
|
|
if "software" in node:
|
|
|
if "firmware" in node["software"]:
|
|
|
- if "release" in node["software"]["firmware"]:
|
|
|
- info_fw = " firmware=" + str(node["software"]["firmware"]["release"])
|
|
|
- else:
|
|
|
- info_fw = " unknown firmware"
|
|
|
+ info_fw = " firmware=" + str(node["software"]["firmware"])
|
|
|
|
|
|
if "autoupdater" in node["software"]:
|
|
|
- autoupdater = node["software"]["autoupdater"]["branch"] if node["software"]["autoupdater"]["enabled"] else "off"
|
|
|
+ autoupdater = node["software"]["autoupdater"]
|
|
|
info_update = " (autoupdater="+autoupdater+")"
|
|
|
|
|
|
info_uptime = ""
|
|
|
- uptime = -1
|
|
|
- if "statistics" in node and "uptime" in node["statistics"]:
|
|
|
- uptime = int(float(node["statistics"]["uptime"]))
|
|
|
- elif 'uptime' in node:
|
|
|
- uptime = int(float(node['uptime']))
|
|
|
+ uptime = node.get('uptime', -1)
|
|
|
|
|
|
if uptime > 0:
|
|
|
days, rem_d = divmod(uptime, 86400)
|
|
@@ -102,7 +94,10 @@ def ffpb_peerinfo(bot, trigger):
|
|
|
clientcount = int(clientcount)
|
|
|
info_clients = ' clients={0}'.format(clientcount)
|
|
|
|
|
|
- bot.say('[{1}]{2}{3}{4}{5}{6}'.format(info_mac, info_name, info_hw, info_fw, info_update, info_uptime, info_clients))
|
|
|
+ bot.say('[{1}]{2}{3}{4}{5}{6}'.format(
|
|
|
+ info_mac, info_name,
|
|
|
+ info_hw, info_fw, info_update,
|
|
|
+ info_uptime, info_clients))
|
|
|
|
|
|
|
|
|
@willie.module.commands('last-seen')
|
|
@@ -192,8 +187,8 @@ def ffpb_peerlink(bot, trigger):
|
|
|
return
|
|
|
|
|
|
# get node's MAC
|
|
|
- info_mac = node["network"]["mac"]
|
|
|
- info_name = node["hostname"]
|
|
|
+ info_mac = node.get('mac')
|
|
|
+ info_name = node.get('hostname')
|
|
|
|
|
|
# get node's v6 address in the mesh (derived from MAC address)
|
|
|
info_v6 = mac2ipv6(info_mac, 'fdca:ffee:ff12:132:')
|