This commit is contained in:
2026-01-21 23:01:18 -08:00
parent 201663bb62
commit 8225221fd3
2 changed files with 63 additions and 44 deletions

View File

@@ -64,6 +64,18 @@ import time
from typing import Optional
def _ensure_interactive_stdin() -> None:
"""If stdin is piped (e.g. via curl | python), re-open it to the terminal."""
if not sys.stdin.isatty():
try:
if platform.system().lower() == "windows":
sys.stdin = open("CONIN$", "r")
else:
sys.stdin = open("/dev/tty", "r")
except Exception:
pass
def run(cmd: list[str], quiet: bool = False, debug: bool = False, cwd: Optional[Path] = None) -> None:
if debug:
print(f"\n> {' '.join(cmd)}")
@@ -476,6 +488,11 @@ def main() -> int:
)
args = parser.parse_args()
# If stdout is a TTY but stdin is a pipe (e.g. curl | python),
# re-open stdin to the console so interactive prompts work.
if sys.stdout.isatty() and not args.quiet:
_ensure_interactive_stdin()
# Ensure repo_root is always the project root, not the current working directory
# This prevents issues when bootstrap.py is run from different directories
try:
@@ -540,12 +557,14 @@ def main() -> int:
if _is_valid_mm_repo(install_path):
print(f"Found existing repository in {install_path}.")
repo_root = install_path
is_in_repo = True
else:
print(f"Cloning Medeos-Macina into {install_path}...")
print(f"Source: {REPO_URL}")
try:
subprocess.check_call(["git", "clone", REPO_URL, str(install_path)])
repo_root = install_path
is_in_repo = True
except Exception as e:
print(f"Error: Failed to clone repository: {e}", file=sys.stderr)
return 1
@@ -966,7 +985,7 @@ def main() -> int:
return 0
# If no specific action flag is passed and we're in a terminal, show the menu
if sys.stdin.isatty() and not args.quiet:
if (sys.stdin.isatty() or sys.stdout.isatty()) and not args.quiet:
sel = _interactive_menu()
if sel == "install":
# user chose to install/reinstall; set defaults and continue