def show(self, print_result=True, hidden=False, **kwargs): # type: (bool, bool, **Any) -> Optional[str] """ Print list of available network interfaces in human readable form :param print_result: print the results if True, else return it :param hidden: if True, also displays invalid interfaces """ res = defaultdict(list) for iface_name in sorted(self.data): dev = self.data[iface_name] if not hidden and not dev.is_valid(): continue prov = dev.provider res[prov].append((prov.name, ) + prov._format(dev, **kwargs)) output = "" for provider in res: output += pretty_list(res[provider], [("Source", ) + provider.headers], sortBy=provider.header_sort) + "\n" output = output[:-1] if print_result: print(output) return None else: return output
def __repr__(self): rtlst = [] for net, msk, gw, iface, cset, metric in self.routes: rtlst.append(('%s/%i' % (net, msk), gw, (iface if isinstance(iface, six.string_types) else iface.name), ", ".join(cset) if len(cset) > 0 else "", str(metric))) # noqa: E501 return pretty_list(rtlst, [('Destination', 'Next Hop', "Iface", "Src candidates", "Metric")], # noqa: E501 sortBy=1)
def __repr__(self): rtlst = [] for net, msk, gw, iface, addr, metric in self.routes: if_repr = resolve_iface(iface).description rtlst.append( (ltoa(net), ltoa(msk), gw, if_repr, addr, str(metric))) return pretty_list(rtlst, [ ("Network", "Netmask", "Gateway", "Iface", "Output IP", "Metric") ]) # noqa: E501
def __repr__(self): rtlst = [] for net, msk, gw, iface, addr, metric in self.routes: rtlst.append( (ltoa(net), ltoa(msk), gw, (iface.name if not isinstance(iface, six.string_types) else iface), addr, str(metric))) return pretty_list(rtlst, [ ("Network", "Netmask", "Gateway", "Iface", "Output IP", "Metric") ])
def __repr__(self): # type: () -> str rtlst = [] # type: List[Tuple[Union[str, List[str]], ...]] for net, msk, gw, iface, addr, metric in self.routes: if_repr = cast(str, resolve_iface(iface).description) rtlst.append( (ltoa(net), ltoa(msk), gw, if_repr, addr, str(metric))) return pretty_list(rtlst, [ ("Network", "Netmask", "Gateway", "Iface", "Output IP", "Metric") ]) # noqa: E501
def __repr__(self): rtlst = [] for net, msk, gw, iface, addr, metric in self.routes: rtlst.append((ltoa(net), ltoa(msk), gw, (iface.name if not isinstance(iface, six.string_types) else iface), # noqa: E501 addr, str(metric))) return pretty_list(rtlst, [("Network", "Netmask", "Gateway", "Iface", "Output IP", "Metric")]) # noqa: E501
def __repr__(self): rtlst = [] for net, msk, gw, iface, cset, metric in self.routes: if_repr = resolve_iface(iface).description rtlst.append( ('%s/%i' % (net, msk), gw, if_repr, cset, str(metric))) return pretty_list( rtlst, [('Destination', 'Next Hop', "Iface", "Src candidates", "Metric") ], # noqa: E501 sortBy=1)
def __repr__(self): rtlst = [] for net, msk, gw, iface, cset, metric in self.routes: rtlst.append( ('%s/%i' % (net, msk), gw, (iface if isinstance( iface, six.string_types) else iface.description), ", ".join(cset) if len(cset) > 0 else "", str(metric))) return pretty_list( rtlst, [('Destination', 'Next Hop', "Iface", "Src candidates", "Metric") ], # noqa: E501 sortBy=1)
def show(self, resolve_mac=True, print_result=True): """Print list of available network interfaces in human readable form""" res = [] for iface_name in sorted(self.data): dev = self.data[iface_name] mac = dev.mac if resolve_mac and conf.manufdb: mac = conf.manufdb._resolve_MAC(mac) res.append((str(dev.win_index), str(dev.name), str(dev.ip), mac)) res = pretty_list(res, [("INDEX", "IFACE", "IP", "MAC")]) if print_result: print(res) else: return res
def __repr__(self): # type: () -> str rtlst = [] # type: List[Tuple[Union[str, List[str]], ...]] for net, msk, gw, iface, cset, metric in self.routes: if_repr = cast(str, resolve_iface(iface).description) rtlst.append(('%s/%i' % (net, msk), gw, if_repr, cset, str(metric))) return pretty_list(rtlst, [('Destination', 'Next Hop', "Iface", "Src candidates", "Metric")], # noqa: E501 sortBy=1)
def show(self, resolve_mac=True, print_result=True): """Print list of available network interfaces in human readable form""" res = [] for iface_name in sorted(self.data): dev = self.data[iface_name] mac = dev.mac if resolve_mac and conf.manufdb: mac = conf.manufdb._resolve_MAC(mac) res.append((str(dev.win_index).ljust(5), str(dev.name).ljust(35), str(dev.ip).ljust(15), mac)) res = pretty_list(res, [("INDEX", "IFACE", "IP", "MAC")]) if print_result: print(res) else: return res
def show(self, resolve_mac=True, print_result=True): """Print list of available network interfaces in human readable form""" res = [] for iface_name in sorted(self.data): dev = self.data[iface_name] mac = dev.mac if resolve_mac and conf.manufdb: mac = conf.manufdb._resolve_MAC(mac) validity_color = lambda x: conf.color_theme.red if x else \ conf.color_theme.green description = validity_color(dev.is_invalid())(str( dev.description)) index = str(dev.win_index) res.append((index, description, str(dev.ip), mac)) res = pretty_list(res, [("INDEX", "IFACE", "IP", "MAC")], sortBy=2) if print_result: print(res) else: return res