def get_iface_status_raw(interface): """list the raw status of interfaces.""" cli_args = [x for x in get_iface_status_raw_cmd_args()] theRawIfaceState = None stderrdata = None tainted_name = interfaces.taint_name(interface) if (tainted_name is not None) and (tainted_name not in cli_args): cli_args.append(str(tainted_name)) p0 = subprocess.Popen(args=cli_args, shell=False, universal_newlines=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) try: (theRawIfaceState, stderrdata) = p0.communicate(str(os.linesep)) except Exception: p0.kill() theRawIfaceState = None finally: p0.wait() if stderrdata: # pragma: no branch theRawIfaceState = None return theRawIfaceState
def get_iface_name(iface_name=None, use_html=False): tainted_iface_name = interfaces.taint_name(iface_name) if tainted_iface_name is None: return None if use_html is not True: return tainted_iface_name else: iface = str(get_iface_name(tainted_iface_name, False)) return html_generator.gen_html_td( iface, str(u'iface_status_dev_{}').format(iface))
def get_iface_status(iface, use_html=False): """Generate the status""" theResult = None tainted_name = interfaces.taint_name(iface) if tainted_name not in get_iface_list(): return theResult status_txt = get_iface_status_raw(iface) if use_html is False: theResult = _extractIFaceStatus(status_txt) else: theResult = generate_iface_status_html(iface, status_txt) return theResult
def get_iface_mac(iface, use_html=False): """Generate output of the iface mac.""" theResult = None tainted_name = interfaces.taint_name(iface) mac_list_txt = utils.extractMACAddr(get_iface_status_raw(tainted_name)) if use_html is False: if mac_list_txt is not None and (len(mac_list_txt) > 0): theResult = str(mac_list_txt[0]) else: theResult = None else: if mac_list_txt is not None and (len(mac_list_txt) > 0): theResult = html_generator.gen_html_td( str(mac_list_txt[0]), str(u'iface_status_mac_{}').format(tainted_name)) else: theResult = html_generator.gen_html_td( "", str(u'iface_status_mac_{}').format(tainted_name)) return theResult
def taint_name(rawtxt): """check the interface arguments""" return interfaces.taint_name(rawtxt)