MCPcopy Index your code
hub / github.com/theskumar/python-dotenv / run_command

Function run_command

src/dotenv/cli.py:204–236  ·  view source on GitHub ↗

Replace the current process with the specified command. Replaces the current process with the specified command and the variables from `env` added in the current environment variables. Parameters ---------- command: List[str] The command and it's parameters env: Dic

(command: List[str], env: Dict[str, str])

Source from the content-addressed store, hash-verified

202
203
204def run_command(command: List[str], env: Dict[str, str]) -> None:
205 """Replace the current process with the specified command.
206
207 Replaces the current process with the specified command and the variables from `env`
208 added in the current environment variables.
209
210 Parameters
211 ----------
212 command: List[str]
213 The command and it's parameters
214 env: Dict
215 The additional environment variables
216
217 Returns
218 -------
219 None
220 This function does not return any value. It replaces the current process with the new one.
221
222 """
223 # copy the current environment variables and add the vales from
224 # `env`
225 cmd_env = os.environ.copy()
226 cmd_env.update(env)
227
228 if sys.platform == "win32":
229 # execvpe on Windows returns control immediately
230 # rather than once the command has finished.
231 p = Popen(command, universal_newlines=True, bufsize=0, shell=False, env=cmd_env)
232 _, _ = p.communicate()
233
234 sys.exit(p.returncode)
235 else:
236 os.execvpe(command[0], args=command, env=cmd_env)

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…