def create_process_wrapper(executor, command, working_directory, env_variables): run_pty = executor.config.requires_terminal if run_pty and not os_utils.is_pty_supported(): LOGGER.warning( "Requested PTY mode, but it's not supported for this OS (" + sys.platform + '). Falling back to POpen') run_pty = False if run_pty: from execution import process_pty process_wrapper = process_pty.PtyProcessWrapper(command, working_directory, env_variables) else: process_wrapper = process_popen.POpenProcessWrapper(command, working_directory, env_variables) return process_wrapper
def start(self, process_constructor=None): if self.process_wrapper is not None: raise Exception('Executor already started') script_args = build_command_args(self.parameter_values, self.config) command = self.script_base_command + script_args if process_constructor: process_wrapper = process_constructor(command, self.working_directory) else: run_pty = self.config.is_requires_terminal() if run_pty and not os_utils.is_pty_supported(): LOGGER.warning( "Requested PTY mode, but it's not supported for this OS (" + sys.platform + '). Falling back to POpen') run_pty = False if run_pty: from execution import process_pty process_wrapper = process_pty.PtyProcessWrapper( command, self.working_directory) else: process_wrapper = process_popen.POpenProcessWrapper( command, self.working_directory) process_wrapper.start() self.process_wrapper = process_wrapper self.output_stream = process_wrapper.output_stream \ .time_buffered(TIME_BUFFER_MS, _concat_output) if self.secure_replacements: self.secure_output_stream = self.output_stream \ .map(self.__replace_secure_variables) else: self.secure_output_stream = self.output_stream return process_wrapper.get_process_id()