userver: en/testsuite/utils/subprocess_helper.py Source File
Loading...
Searching...
No Matches
subprocess_helper.py
1import subprocess
2
3
4def sh(*args: str, nostderr: bool = True) -> str: # pylint: disable=invalid-name
5 stderr: int | None
6 if nostderr:
7 stderr = subprocess.DEVNULL
8 else:
9 stderr = None
10 proc = subprocess.run(
11 args,
12 stdout=subprocess.PIPE,
13 stderr=stderr,
14 encoding='utf-8',
15 check=True,
16 )
17 return proc.stdout.strip()