Skip to content

myke.run

Functions that wrap around subprocess.run for added convenience.

Functions

run

run(args: str | Sequence[str], capture_output: None | bool = False, echo: bool | None = True, check: bool | None = True, env: dict[str, str] | None = None, env_update: dict[str, str | None] | None = None, shell: bool | None = None, **kwargs: Any) -> subprocess.CompletedProcess[bytes | str]

Thin wrapper around subprocess.run

PARAMETER DESCRIPTION
args

...

TYPE: str | Sequence[str]

capture_output

...

TYPE: None | bool DEFAULT: False

echo

...

TYPE: bool | None DEFAULT: True

check

...

TYPE: bool | None DEFAULT: True

env

...

TYPE: dict[str, str] | None DEFAULT: None

env_update

...

TYPE: dict[str, str | None] | None DEFAULT: None

shell

...

TYPE: bool | None DEFAULT: None

**kwargs

passed to subprocess.run(...)

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
CompletedProcess[bytes | str]

...

Examples:

>>> import myke
...
>>> myke.run(["python", "-c", "print('Hello World.')"])
CompletedProcess(args=['python', '-c', "print('Hello World.')"], returncode=0)
>>> myke.run("echo 'Hello World.'")
CompletedProcess(args="echo 'Hello World.'", returncode=0)
>>> p = myke.run("echo 'Hello World.'", capture_output=True, echo=False)
>>> p.stdout
b'Hello World.\n'
>>> p = myke.run("exit 123", check=False)
>>> p.returncode
123

sh

sh(*args: Any, **kwargs: Any) -> subprocess.CompletedProcess[bytes | str]

Shorthand for: myke.run(..., shell=True)

PARAMETER DESCRIPTION
*args

...

TYPE: Any DEFAULT: ()

**kwargs

...

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
CompletedProcess[bytes | str]

...