MCPcopy Index your code
hub / github.com/certbot/certbot / run_script

Function run_script

certbot/src/certbot/util.py:176–203  ·  view source on GitHub ↗

Run the script with the given params. :param list params: List of parameters to pass to subprocess.run :param callable log: Logger method to use for errors

(params: list[str], log: Callable[[str], None]=logger.error)

Source from the content-addressed store, hash-verified

174
175
176def run_script(params: list[str], log: Callable[[str], None]=logger.error) -> tuple[str, str]:
177 """Run the script with the given params.
178
179 :param list params: List of parameters to pass to subprocess.run
180 :param callable log: Logger method to use for errors
181
182 """
183 try:
184 proc = subprocess.run(params,
185 check=False,
186 stdout=subprocess.PIPE,
187 stderr=subprocess.PIPE,
188 universal_newlines=True,
189 env=env_no_snap_for_external_calls())
190
191 except (OSError, ValueError):
192 msg = "Unable to run the command: %s" % " ".join(params)
193 log(msg)
194 raise errors.SubprocessError(msg)
195
196 if proc.returncode != 0:
197 msg = "Error while running %s.\n%s\n%s" % (
198 " ".join(params), proc.stdout, proc.stderr)
199 # Enter recovery routine...
200 log(msg)
201 raise errors.SubprocessError(msg)
202
203 return proc.stdout, proc.stderr
204
205
206def exe_exists(exe: str) -> bool:

Callers 1

_callMethod · 0.90

Calls 2

runMethod · 0.80

Tested by 1

_callMethod · 0.72