Tools¶
tools
¶
Low-level runtime utilities: user prompts and subprocess execution.
Sections
- User interaction: prompt helpers
- Subprocess: wrappers around subprocess.run and shell script execution
Functions:
| Name | Description |
|---|---|
ask |
Ask a yes/no question via input() and return their answer. |
get_exec_dir |
Return the directory where the current script is located. |
run |
Run a subprocess command and optionally capture its output. |
run_script |
Run a shell script and return its output as a string. |
get_exec_dir
¶
run
¶
run(cmd: list, check: bool = True, capture: bool = False, cwd: Optional[str] = None, name: Optional[str] = None) -> Optional[str]
Run a subprocess command and optionally capture its output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list
|
Command and arguments to execute. |
required |
|
bool
|
If True, raise CalledProcessError on non-zero exit. Defaults to True. |
True
|
|
bool
|
If True, capture and return stdout. Defaults to False. |
False
|
|
Optional[str]
|
Working directory for the subprocess. Defaults to None. |
None
|
|
Optional[str]
|
Label used in debug log output. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Captured stdout as a string if capture is True, otherwise None. |
Source code in oops/io/tools.py
run_script
¶
Run a shell script and return its output as a string.