def run(self, args): clients = self.serverapi.get('clients').findall('Server') headers = ['Name', 'Host', 'Product', 'Class', 'Capabilities'] getcaps = lambda x: ', '.join(x['protocolCapabilities'].split(',')) accessors = ['name', 'host', 'product', 'deviceClass', getcaps] t = Table(headers=headers, accessors=accessors) t.print([x.attrib for x in clients])
def run(self, args): if args.idents: routers = [self.api.get_by_id_or_name('routers', x) for x in args.idents] else: routers = self.api.get_pager('routers') ids = dict((x['id'], x['name']) for x in routers if x['state'] == 'online') if not ids: raise SystemExit("No online routers found") data = [] for clients in self.api.get_pager('remote', '/status/lan/clients', id__in=','.join(ids)): if not clients['success']: continue for x in clients['data']: x['router'] = ids[str(clients['id'])] data.append(x) dns_getter = self.make_dns_getter(ids) headers = ['Router', 'IP Address', 'Hostname', 'MAC', 'Hardware'] accessors = ['router', 'ip_address', dns_getter, 'mac'] if not args.verbose: accessors.append(self.mac_lookup_short) else: wifi_getter = self.make_wifi_getter(ids) headers.extend(['WiFi Signal', 'WiFi Speed']) na = '<dim>n/a</dim>' accessors.extend([ self.mac_lookup_long, lambda x: wifi_getter(x).get('rssi0', na), lambda x: wifi_getter(x).get('txrate', na) ]) table = Table(headers=headers, accessors=accessors) table.print(data)
def run(self, args): headers = ['Date', 'Type', 'Message'] accessors = [self.get_ts, self.get_type, self.get_msg] table = Table(headers=headers, accessors=accessors) evloop = asyncio.get_event_loop() with evloop.run_until_complete(self.notifications(table)): pass