mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-05 18:22:41 +00:00
try run command
This commit is contained in:
parent
3673c98c9a
commit
47874e5a25
2 changed files with 8 additions and 4 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
import importlib.resources
|
import importlib.resources
|
||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
from pathlib import Path
|
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.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
|
from llama_stack.providers.datatypes import Api
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -147,7 +148,12 @@ def build_image(
|
||||||
if special_deps:
|
if special_deps:
|
||||||
args.append("#".join(special_deps))
|
args.append("#".join(special_deps))
|
||||||
|
|
||||||
|
is_terminal = sys.stdin.isatty()
|
||||||
|
if is_terminal:
|
||||||
return_code = run_with_pty(args)
|
return_code = run_with_pty(args)
|
||||||
|
else:
|
||||||
|
return_code = run_command(args)
|
||||||
|
|
||||||
if return_code != 0:
|
if return_code != 0:
|
||||||
log.error(
|
log.error(
|
||||||
f"Failed to build target {build_config.name} with return code {return_code}",
|
f"Failed to build target {build_config.name} with return code {return_code}",
|
||||||
|
|
|
@ -22,9 +22,7 @@ log = logging.getLogger(__name__)
|
||||||
def run_with_pty(command):
|
def run_with_pty(command):
|
||||||
master, slave = pty.openpty()
|
master, slave = pty.openpty()
|
||||||
|
|
||||||
# Check if stdin is actually a terminal
|
|
||||||
old_settings = termios.tcgetattr(sys.stdin)
|
old_settings = termios.tcgetattr(sys.stdin)
|
||||||
|
|
||||||
original_sigint = signal.getsignal(signal.SIGINT)
|
original_sigint = signal.getsignal(signal.SIGINT)
|
||||||
|
|
||||||
ctrl_c_pressed = False
|
ctrl_c_pressed = False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue