MCPcopy Create free account
hub / github.com/theskumar/python-dotenv / run_command

Function run_command

src/dotenv/cli.py:168–199  ·  view source on GitHub ↗

Run command in sub process. Runs the command in a sub process with the variables from `env` added in the current environment variables. Parameters ---------- command: List[str] The command and it's parameters env: Dict The additional environment variables

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

Source from the content-addressed store, hash-verified

166
167
168def run_command(command: List[str], env: Dict[str, str]) -> int:
169 """Run command in sub process.
170
171 Runs the command in a sub process with the variables from `env`
172 added in the current environment variables.
173
174 Parameters
175 ----------
176 command: List[str]
177 The command and it's parameters
178 env: Dict
179 The additional environment variables
180
181 Returns
182 -------
183 int
184 The return code of the command
185
186 """
187 # copy the current environment variables and add the vales from
188 # `env`
189 cmd_env = os.environ.copy()
190 cmd_env.update(env)
191
192 p = Popen(command,
193 universal_newlines=True,
194 bufsize=0,
195 shell=False,
196 env=cmd_env)
197 _, _ = p.communicate()
198
199 return p.returncode

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected