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,
)
| 307 | |
| 308 | |
| 309 | def _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 |
no test coverage detected