def wait(self, input_str=None): """Wait for subprocess to complete and exit, collect and decode ``stdout`` and ``stderr``, returning the tuple ``(exit_code, stdout, stderr)```""" if self.process is not None: stdout, stderr = self.process.communicate(Utils.encode_bytes(input_str if input_str else '')) exit_code = self.process.wait() # Ensure that we reap the file descriptors. self.cleanup() return (exit_code, Utils.decode_bytes(stdout), Utils.decode_bytes(stderr)) return (-1, '', self.process_err or "?? unknown error -- no process.")
def wait(self, input_str=None): """Wait for subprocess to complete and exit, collect and decode ``stdout`` and ``stderr``, returning the tuple ``(exit_code, stdout, stderr)```""" if self.process is not None: stdout, stderr = self.process.communicate(Utils.encode_bytes(input_str) if input_str is not None else '') exit_code = self.process.wait() # Ensure that we reap the file descriptors. self.cleanup() return (exit_code, Utils.decode_bytes(stdout), Utils.decode_bytes(stderr)) else: return (-1, '', self.process_err or "?? unknown error -- no process.")
def run(self): while not self.stop_me.is_set(): line = self.fobject.readline() if isinstance(line, bytearray): line = Utils.decode_bytes(line) line = line.rstrip() print('<{0}> {1}'.format(self.label, line))
def run(self): while not self.stop_me.is_set(): line = self.fobject.readline() if not isinstance(line, ''.__class__): line = Utils.decode_bytes(line) if line != '': line = line.rstrip() print('<{0}> {1}'.format(self.label, line)) else: # Got EOF. Stop. self.stop()