Skip to content

Commit ec18fb5

Browse files
committed
Allow for disabling pseudo-terminals
1 parent f260090 commit ec18fb5

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1111
***Added:***
1212

1313
- No longer build pre-configured Python distributions for release builds
14+
- The top-level `--interactive` flag now disables the use of pseudo-terminals for subprocesses
1415

1516
***Fixed:***
1617

src/dda/cli/terminal.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def __init__(self, *, config: TerminalConfig, enable_color: bool | None, interac
2626
# Force consistent output for test assertions
2727
self.testing = "DDA_SELF_TESTING" in os.environ
2828

29+
self.force_interactive = interactive is True
2930
self.console = Console(
3031
force_terminal=enable_color,
3132
force_interactive=interactive,

src/dda/utils/process.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,19 @@ def __run(
251251
check: bool,
252252
capture: bool,
253253
) -> tuple[int, str]:
254+
if self.__app.force_interactive:
255+
import subprocess
256+
257+
kwargs = {"env": env, "cwd": cwd}
258+
if capture:
259+
kwargs["encoding"] = encoding
260+
kwargs["stdout"] = subprocess.PIPE
261+
kwargs["stderr"] = subprocess.STDOUT
262+
263+
command, kwargs = self.__sanitize_arguments(command, **kwargs)
264+
process = subprocess.run(command, **kwargs) # noqa: PLW1510
265+
return process.returncode, process.stdout if capture else ""
266+
254267
import tempfile
255268
import threading
256269

0 commit comments

Comments
 (0)