MCPcopy Index your code
hub / github.com/bugy/script-server / invoke

Method invoke

src/utils/process_utils.py:20–43  ·  view source on GitHub ↗
(self, command, work_dir='.', *, environment_variables: dict = None, check_stderr=True, shell=False)

Source from the content-addressed store, hash-verified

18 self._env_vars = env_vars
19
20 def invoke(self, command, work_dir='.', *, environment_variables: dict = None, check_stderr=True, shell=False):
21 if isinstance(command, str) and not shell:
22 command = split_command(command, working_directory=work_dir)
23
24 env_vars = self._env_vars.build_env_vars(environment_variables)
25
26 p = subprocess.Popen(command,
27 stdout=subprocess.PIPE,
28 stderr=subprocess.PIPE,
29 cwd=work_dir,
30 env=env_vars,
31 universal_newlines=True,
32 shell=shell)
33
34 (output, error) = p.communicate()
35
36 result_code = p.returncode
37 if result_code != 0:
38 raise ExecutionException(result_code, error, output)
39
40 if error and check_stderr:
41 LOGGER.warning("Error output wasn't empty, although the command finished with code 0!")
42
43 return output
44
45
46def split_command(script_command, working_directory=None):

Callers 9

create_version_fileFunction · 0.95
build_web_filesFunction · 0.95
verifyMethod · 0.80
is_installedMethod · 0.80
run_preload_scriptMethod · 0.80
get_script_outputMethod · 0.80
sendMethod · 0.80
__init__Method · 0.80
get_valuesMethod · 0.80

Calls 3

split_commandFunction · 0.85
ExecutionExceptionClass · 0.85
build_env_varsMethod · 0.80

Tested by

no test coverage detected