コード例 #1
0
    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.")
コード例 #2
0
 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.")