def set_std_channels(self): i = ioman.rchannel(ioman.primitive_channel_fd(0, 1)) o = ioman.wchannel(ioman.primitive_channel_fd(1, 1)) e = ioman.wchannel(ioman.primitive_channel_fd(2, 1)) self.add_rchannel(i) self.add_wchannel(o) self.add_wchannel(e) self.stdin = i # read my stdin from i self.stdout = o # write to my stdout via o self.stderr = e # write to my stderr via e
def get_my_addrs_by_ifconfig(self): patterns = [ re.compile("inet addr:([\d|\.]+)"), re.compile("inet ([\d|\.]+)") ] addrs = [] for c in self.ifconfig_cmds: r = os.popen(c) if ioman is None: ifconfig_out = r.read() else: pr = ioman.primitive_channel_fd(r.fileno(), 1) ifconfig_outs = [] while 1: l,err,msg = pr.read(1000) if l <= 0: break ifconfig_outs.append(msg) ifconfig_out = string.join(ifconfig_outs, "") for p in patterns: found = p.findall(ifconfig_out) if len(found) > 0: break for addr in found: if self.parse_ip_addr(addr) is not None: addrs.append(addr) # ??? we got: # "close failed: [Errno 9] Bad file descriptor" # r.close() # pr.close() if len(addrs) > 0: return addrs return []
def get_my_addrs_by_ifconfig(self): patterns = [ re.compile("inet addr:([\d|\.]+)"), re.compile("inet ([\d|\.]+)") ] addrs = [] for c in self.ifconfig_cmds: r = os.popen(c) if ioman is None: ifconfig_out = r.read() else: pr = ioman.primitive_channel_fd(r.fileno(), 1) ifconfig_outs = [] while 1: l, err, msg = pr.read(1000) if l <= 0: break ifconfig_outs.append(msg) ifconfig_out = string.join(ifconfig_outs, "") for p in patterns: found = p.findall(ifconfig_out) if len(found) > 0: break for addr in found: if self.parse_ip_addr(addr) is not None: addrs.append(addr) # ??? we got: # "close failed: [Errno 9] Bad file descriptor" # r.close() # pr.close() if len(addrs) > 0: return addrs return []