diff --git a/moonraker/components/update_manager/app_deploy.py b/moonraker/components/update_manager/app_deploy.py index a689061..77896f2 100644 --- a/moonraker/components/update_manager/app_deploy.py +++ b/moonraker/components/update_manager/app_deploy.py @@ -38,12 +38,14 @@ if TYPE_CHECKING: SUPPORTED_CHANNELS = { AppType.WEB: [Channel.STABLE, Channel.BETA], AppType.ZIP: [Channel.STABLE, Channel.BETA], - AppType.GIT_REPO: list(Channel) + AppType.GIT_REPO: list(Channel), + AppType.PYTHON: list(Channel) } TYPE_TO_CHANNEL = { AppType.WEB: Channel.STABLE, AppType.ZIP: Channel.STABLE, - AppType.GIT_REPO: Channel.DEV + AppType.GIT_REPO: Channel.DEV, + AppType.PYTHON: Channel.STABLE } DISTRO_ALIASES = [distro.id()] diff --git a/moonraker/components/update_manager/common.py b/moonraker/components/update_manager/common.py index 4498ef1..7221af6 100644 --- a/moonraker/components/update_manager/common.py +++ b/moonraker/components/update_manager/common.py @@ -52,25 +52,30 @@ class AppType(ExtendedEnum): WEB = 2 GIT_REPO = 3 ZIP = 4 + PYTHON = 5 + + @classmethod + def detect(cls, app_path: Union[str, pathlib.Path, None] = None): + # If app path is None, detect Moonraker + if isinstance(app_path, str): + app_path = pathlib.Path(app_path).expanduser() + if source_info.is_git_repo(app_path): + return AppType.GIT_REPO + elif app_path is None and source_info.is_vitualenv_project(): + return AppType.PYTHON + else: + return AppType.NONE + class Channel(ExtendedEnum): STABLE = 1 BETA = 2 DEV = 3 -def get_app_type(app_path: Union[str, pathlib.Path]) -> AppType: - if isinstance(app_path, str): - app_path = pathlib.Path(app_path).expanduser() - # None type will perform checks on Moonraker - if source_info.is_git_repo(app_path): - return AppType.GIT_REPO - else: - return AppType.NONE - def get_base_configuration(config: ConfigHelper) -> ConfigHelper: server = config.get_server() base_cfg = copy.deepcopy(BASE_CONFIG) - base_cfg["moonraker"]["type"] = str(get_app_type(source_info.source_path())) + base_cfg["moonraker"]["type"] = str(AppType.detect()) db: MoonrakerDatabase = server.lookup_component('database') base_cfg["klipper"]["path"] = db.get_item( "moonraker", "update_manager.klipper_path", KLIPPER_DEFAULT_PATH @@ -78,7 +83,7 @@ def get_base_configuration(config: ConfigHelper) -> ConfigHelper: base_cfg["klipper"]["env"] = db.get_item( "moonraker", "update_manager.klipper_exec", KLIPPER_DEFAULT_EXEC ).result() - base_cfg["klipper"]["type"] = str(get_app_type(base_cfg["klipper"]["path"])) + base_cfg["klipper"]["type"] = str(AppType.detect(base_cfg["klipper"]["path"])) channel = config.get("channel", "dev") base_cfg["moonraker"]["channel"] = channel base_cfg["klipper"]["channel"] = channel diff --git a/moonraker/components/update_manager/update_manager.py b/moonraker/components/update_manager/update_manager.py index b934cc4..0458322 100644 --- a/moonraker/components/update_manager/update_manager.py +++ b/moonraker/components/update_manager/update_manager.py @@ -11,11 +11,12 @@ import logging import time import tempfile import pathlib -from .common import AppType, get_base_configuration, get_app_type +from .common import AppType, get_base_configuration from .base_deploy import BaseDeploy from .app_deploy import AppDeploy from .git_deploy import GitDeploy from .zip_deploy import ZipDeploy +from .python_deploy import PythonDeploy from .system_deploy import PackageDeploy from ...common import RequestType from ...utils.filelock import AsyncExclusiveFileLock, LockTimeout @@ -58,7 +59,8 @@ def get_deploy_class( _deployers = { AppType.WEB: ZipDeploy, AppType.GIT_REPO: GitDeploy, - AppType.ZIP: ZipDeploy + AppType.ZIP: ZipDeploy, + AppType.PYTHON: PythonDeploy } return _deployers.get(key, default) @@ -209,7 +211,7 @@ class UpdateManager: kpath: str = kinfo['klipper_path'] executable: str = kinfo['python_path'] kupdater = self.updaters.get('klipper') - app_type = get_app_type(kpath) + app_type = AppType.detect(kpath) if ( (isinstance(kupdater, AppDeploy) and kupdater.check_same_paths(kpath, executable)) or