try run command

This commit is contained in:
Xi Yan 2025-01-14 15:03:32 -08:00
parent 3673c98c9a
commit 47874e5a25
2 changed files with 8 additions and 4 deletions

View file

@ -6,6 +6,7 @@
import importlib.resources
import logging
import sys
from enum import Enum
from pathlib import Path
@ -20,7 +21,7 @@ from llama_stack.distribution.distribution import get_provider_registry
from llama_stack.distribution.utils.config_dirs import BUILDS_BASE_DIR
from llama_stack.distribution.utils.exec import run_with_pty
from llama_stack.distribution.utils.exec import run_command, run_with_pty
from llama_stack.providers.datatypes import Api
log = logging.getLogger(__name__)
@ -147,7 +148,12 @@ def build_image(
if special_deps:
args.append("#".join(special_deps))
return_code = run_with_pty(args)
is_terminal = sys.stdin.isatty()
if is_terminal:
return_code = run_with_pty(args)
else:
return_code = run_command(args)
if return_code != 0:
log.error(
f"Failed to build target {build_config.name} with return code {return_code}",

View file

@ -22,9 +22,7 @@ log = logging.getLogger(__name__)
def run_with_pty(command):
master, slave = pty.openpty()
# Check if stdin is actually a terminal
old_settings = termios.tcgetattr(sys.stdin)
original_sigint = signal.getsignal(signal.SIGINT)
ctrl_c_pressed = False