import re class wireless: def __init__(self, device = "wlan0"): self.device = device self.__link = "" self.__level = "" self.__noise = "" def __parse(self): f = open("/proc/net/wireless", "r") for line in f: line = line.strip() if re.match("^" + self.device + ".*$", line): line = re.sub("\s+", " ", line) lst = line.split(" ") self.__link = lst[2] self.__level = lst[3] self.__noise = lst[4] break f.close() def level(self): self.__parse() return self.__level def link(self): self.__parse() return self.__link def noise(self): self.__parse() return self.__noise