fix rich autodetection of TTY, USE_COLOR, SHOW_PROGRESS

This commit is contained in:
Nick Sweeting
2024-09-24 19:37:29 -07:00
parent bde0bf8263
commit 0dffbf1bb4
4 changed files with 32 additions and 17 deletions

View File

@@ -41,6 +41,7 @@ import importlib.metadata
from pydantic_pkgr import SemVer
from rich.progress import Progress
from rich.console import Console
import django
from django.db.backends.sqlite3.base import Database as sqlite3
@@ -55,8 +56,6 @@ from .config_stubs import (
)
from .misc.logging import (
CONSOLE,
SHOW_PROGRESS,
DEFAULT_CLI_COLORS,
ANSI,
COLOR_DICT,
@@ -1289,6 +1288,17 @@ if not CONFIG['CHECK_SSL_VALIDITY']:
########################### Config Validity Checkers ###########################
if not CONFIG.USE_COLOR:
os.environ['NO_COLOR'] = '1'
if not CONFIG.SHOW_PROGRESS:
os.environ['TERM'] = 'dumb'
# recreate rich console obj based on new config values
CONSOLE = Console()
from .misc import logging
logging.CONSOLE = CONSOLE
INITIAL_STARTUP_PROGRESS = None
INITIAL_STARTUP_PROGRESS_TASK = 0