def _load_script_config(path, content_or_json_dict): if isinstance(content_or_json_dict, str): json_object = json.loads(content_or_json_dict) else: json_object = content_or_json_dict return script_configs.from_json(path, json_object, os_utils.is_pty_supported())
def find_and_load(path, content): try: config_name = script_configs.read_name(path, content) if config_name == name: return script_configs.from_json(path, content, os_utils.is_pty_supported()) except: LOGGER.exception('Could not load script config: ' + path)
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 create_process_wrapper(executor, command, working_directory): 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) else: process_wrapper = process_popen.POpenProcessWrapper(command, working_directory) return process_wrapper
def _load_script_config(self, path, content_or_json_dict, user, parameter_values): if isinstance(content_or_json_dict, str): json_object = json.loads(content_or_json_dict) else: json_object = content_or_json_dict config = script_config.ConfigModel( json_object, path, user.get_username(), user.get_audit_name(), pty_enabled_default=os_utils.is_pty_supported(), ansi_enabled_default=os_utils.is_linux() or os_utils.is_mac(), parameter_values=parameter_values) return config
def _load_script_config(self, path, content_or_json_dict, user): if isinstance(content_or_json_dict, str): json_object = json.loads(content_or_json_dict) else: json_object = content_or_json_dict config = script_configs.read_full( path, json_object, user.get_username(), user.get_audit_name(), os_utils.is_pty_supported()) self._cached_configs[config.name] = config return config
def _load_script_config(path, content_or_json_dict, user, parameter_values, skip_invalid_parameters): if isinstance(content_or_json_dict, str): json_object = json.loads(content_or_json_dict) else: json_object = content_or_json_dict config = script_config.ConfigModel( json_object, path, user.get_username(), user.get_audit_name(), pty_enabled_default=os_utils.is_pty_supported()) if parameter_values is not None: config.set_all_param_values(parameter_values, skip_invalid_parameters) return config
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()