def getInfo(card_name): """ Returns the dict containing info regarding the wireless card. Dict : {name, channel, ipv4, mac, status} Arguments : card_name -- name of the wireless card """ c = pyw.getcard(card_name) channel = Wireless.getChannel(card_name) status = "" if pyw.isup(c): status = "up" else: status = "down" # one of this function disables during root so autload whichever available. ipv4 = None if "inetget" in dir(pyw): ipv4 = pyw.inetget(c)[0] elif "ifaddrget" in dir(pyw): ipv4 = pyw.ifaddrget(c)[0] mac = pyw.macget(c) return { "name": str(card_name), "channel": str(channel), "ipv4": str(ipv4), "mac": str(mac), "status": str(status) }
def getIfaceIpAddr(self, ifaceName): w0 = self.get_wifi_chard(ifaceName) # get a card for interface ip = pyw.inetget(w0)[0] return ip
def test_inetgetset(self): self.assertEqual(None,pyw.inetset(self.card,pri['ip'],pri['mask'],pri['bcast'])) self.assertEqual(pri['ip'],pyw.inetget(self.card)[0])