mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-04 21:36:14 +02:00
Default value is now 'local-git' (was 'local_git'). Dashes are easier to type and more conventional in HTTP-header-adjacent identifiers. Tests updated accordingly. Amp-Thread-ID: https://ampcode.com/threads/T-019df26e-96f4-7518-94da-0e4263680e3c Co-authored-by: Amp <amp@ampcode.com>
30 lines
839 B
Python
30 lines
839 B
Python
import functools
|
|
import logging
|
|
import os
|
|
|
|
import folder_paths
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
_DEFAULT_DEPLOY_ENV = "local-git"
|
|
_ENV_FILENAME = ".comfy_environment"
|
|
|
|
|
|
@functools.cache
|
|
def get_deploy_environment() -> str:
|
|
env_file = os.path.join(folder_paths.base_path, _ENV_FILENAME)
|
|
try:
|
|
with open(env_file, encoding="utf-8") as f:
|
|
# Cap the read so a malformed or maliciously crafted file (e.g.
|
|
# a single huge line with no newline) can't blow up memory.
|
|
first_line = f.readline(128).strip()
|
|
value = "".join(c for c in first_line if 32 <= ord(c) < 127)
|
|
if value:
|
|
return value
|
|
except FileNotFoundError:
|
|
pass
|
|
except Exception as e:
|
|
logger.error("Failed to read %s: %s", env_file, e)
|
|
|
|
return _DEFAULT_DEPLOY_ENV
|