MCPcopy Create free account
hub / github.com/saltstack/salt / _run

Function _run

salt/modules/cmdmod.py:309–1056  ·  view source on GitHub ↗

Do the DRY thing and only call subprocess.Popen() once

(
    cmd,
    cwd=None,
    stdin=None,
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE,
    output_encoding=None,
    output_loglevel="debug",
    log_callback=None,
    runas=None,
    group=None,
    shell=DEFAULT_SHELL,
    python_shell=False,
    env=None,
    clean_env=False,
    prepend_path=None,
    rstrip=True,
    template=None,
    umask=None,
    timeout=None,
    with_communicate=True,
    reset_system_locale=True,
    ignore_retcode=False,
    saltenv=None,
    pillarenv=None,
    pillar_override=None,
    use_vt=False,
    password=None,
    bg=False,
    encoded_cmd=False,
    success_retcodes=None,
    success_stdout=None,
    success_stderr=None,
    windows_codepage=65001,
    **kwargs,
)

Source from the content-addressed store, hash-verified

307
308
309def _run(
310 cmd,
311 cwd=None,
312 stdin=None,
313 stdout=subprocess.PIPE,
314 stderr=subprocess.PIPE,
315 output_encoding=None,
316 output_loglevel="debug",
317 log_callback=None,
318 runas=None,
319 group=None,
320 shell=DEFAULT_SHELL,
321 python_shell=False,
322 env=None,
323 clean_env=False,
324 prepend_path=None,
325 rstrip=True,
326 template=None,
327 umask=None,
328 timeout=None,
329 with_communicate=True,
330 reset_system_locale=True,
331 ignore_retcode=False,
332 saltenv=None,
333 pillarenv=None,
334 pillar_override=None,
335 use_vt=False,
336 password=None,
337 bg=False,
338 encoded_cmd=False,
339 success_retcodes=None,
340 success_stdout=None,
341 success_stderr=None,
342 windows_codepage=65001,
343 **kwargs,
344):
345 """
346 Do the DRY thing and only call subprocess.Popen() once
347 """
348 if "pillar" in kwargs and not pillar_override:
349 pillar_override = kwargs["pillar"]
350 if output_loglevel != "quiet" and _is_valid_shell(shell) is False:
351 log.warning(
352 "Attempt to run a shell command with what may be an invalid shell! "
353 "Check to ensure that the shell <%s> is valid for this user.",
354 shell,
355 )
356
357 output_loglevel = _check_loglevel(output_loglevel)
358 log_callback = _check_cb(log_callback)
359 use_sudo = False
360
361 if runas is None and "__context__" in globals():
362 runas = __context__.get("runas")
363
364 if password is None and "__context__" in globals():
365 password = __context__.get("runas_password")
366

Callers 9

_run_quietFunction · 0.70
_run_all_quietFunction · 0.70
runFunction · 0.70
run_stdoutFunction · 0.70
run_stderrFunction · 0.70
run_allFunction · 0.70
retcodeFunction · 0.70
scriptFunction · 0.70
run_bgFunction · 0.70

Calls 15

recvMethod · 0.95
isaliveMethod · 0.95
closeMethod · 0.95
SaltInvocationErrorClass · 0.90
_is_valid_shellFunction · 0.85
_check_loglevelFunction · 0.85
_check_cbFunction · 0.85
_render_cmdFunction · 0.85
_check_availFunction · 0.85
_prep_powershell_cmdFunction · 0.85
_parse_envFunction · 0.85

Tested by

no test coverage detected