def _parse_exec_script_and_commands(self): # Check for script in function event if 'script' in self.raw_event: self.script_path = f"{self.input_folder}/script.sh" script_content = StrUtils.base64_to_str(self.raw_event['script']) FileUtils.create_file_with_content(self.script_path, script_content) # Container invoked with arguments elif 'cmd_args' in self.raw_event: # Add args self.cmd_args = json.loads(self.raw_event['cmd_args']) # Script to be executed every time (if defined) elif ConfigUtils.read_cfg_var('init_script') is not '': # Add init script self.init_script_path = f"{self.input_folder}/init_script.sh" FileUtils.cp_file(ConfigUtils.read_cfg_var('init_script'), self.init_script_path)
def _parse_exec_script_and_commands(self): # Check for script in function event if 'script' in self.raw_event: self.script_path = f"{self.input_folder}/script.sh" script_content = StrUtils.base64_to_str(self.raw_event['script']) FileUtils.create_file_with_content(self.script_path, script_content) # Container invoked with arguments elif 'cmd_args' in self.raw_event: # Add args self.cmd_args = json.loads(self.raw_event['cmd_args']) # Script to be executed every time (if defined) elif SysUtils.is_var_in_env('INIT_SCRIPT_PATH'): # Add init script self.init_script_path = f"{self.input_folder}/init_script.sh" FileUtils.cp_file(SysUtils.get_env_var("INIT_SCRIPT_PATH"), self.init_script_path)
def test_cp_file(self, mock_cp): FileUtils.cp_file('/tmp/src_file', '/tmp/dst_file') mock_cp.assert_called_once_with('/tmp/src_file', '/tmp/dst_file')