update_manager: add support for python applications
Signed-off-by: Eric Callahan <arksine.code@gmail.com
This commit is contained in:
parent
b8921ca593
commit
96b1c22e28
|
@ -38,12 +38,14 @@ if TYPE_CHECKING:
|
||||||
SUPPORTED_CHANNELS = {
|
SUPPORTED_CHANNELS = {
|
||||||
AppType.WEB: [Channel.STABLE, Channel.BETA],
|
AppType.WEB: [Channel.STABLE, Channel.BETA],
|
||||||
AppType.ZIP: [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 = {
|
TYPE_TO_CHANNEL = {
|
||||||
AppType.WEB: Channel.STABLE,
|
AppType.WEB: Channel.STABLE,
|
||||||
AppType.ZIP: Channel.STABLE,
|
AppType.ZIP: Channel.STABLE,
|
||||||
AppType.GIT_REPO: Channel.DEV
|
AppType.GIT_REPO: Channel.DEV,
|
||||||
|
AppType.PYTHON: Channel.STABLE
|
||||||
}
|
}
|
||||||
|
|
||||||
DISTRO_ALIASES = [distro.id()]
|
DISTRO_ALIASES = [distro.id()]
|
||||||
|
|
|
@ -52,25 +52,30 @@ class AppType(ExtendedEnum):
|
||||||
WEB = 2
|
WEB = 2
|
||||||
GIT_REPO = 3
|
GIT_REPO = 3
|
||||||
ZIP = 4
|
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):
|
class Channel(ExtendedEnum):
|
||||||
STABLE = 1
|
STABLE = 1
|
||||||
BETA = 2
|
BETA = 2
|
||||||
DEV = 3
|
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:
|
def get_base_configuration(config: ConfigHelper) -> ConfigHelper:
|
||||||
server = config.get_server()
|
server = config.get_server()
|
||||||
base_cfg = copy.deepcopy(BASE_CONFIG)
|
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')
|
db: MoonrakerDatabase = server.lookup_component('database')
|
||||||
base_cfg["klipper"]["path"] = db.get_item(
|
base_cfg["klipper"]["path"] = db.get_item(
|
||||||
"moonraker", "update_manager.klipper_path", KLIPPER_DEFAULT_PATH
|
"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(
|
base_cfg["klipper"]["env"] = db.get_item(
|
||||||
"moonraker", "update_manager.klipper_exec", KLIPPER_DEFAULT_EXEC
|
"moonraker", "update_manager.klipper_exec", KLIPPER_DEFAULT_EXEC
|
||||||
).result()
|
).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")
|
channel = config.get("channel", "dev")
|
||||||
base_cfg["moonraker"]["channel"] = channel
|
base_cfg["moonraker"]["channel"] = channel
|
||||||
base_cfg["klipper"]["channel"] = channel
|
base_cfg["klipper"]["channel"] = channel
|
||||||
|
|
|
@ -11,11 +11,12 @@ import logging
|
||||||
import time
|
import time
|
||||||
import tempfile
|
import tempfile
|
||||||
import pathlib
|
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 .base_deploy import BaseDeploy
|
||||||
from .app_deploy import AppDeploy
|
from .app_deploy import AppDeploy
|
||||||
from .git_deploy import GitDeploy
|
from .git_deploy import GitDeploy
|
||||||
from .zip_deploy import ZipDeploy
|
from .zip_deploy import ZipDeploy
|
||||||
|
from .python_deploy import PythonDeploy
|
||||||
from .system_deploy import PackageDeploy
|
from .system_deploy import PackageDeploy
|
||||||
from ...common import RequestType
|
from ...common import RequestType
|
||||||
from ...utils.filelock import AsyncExclusiveFileLock, LockTimeout
|
from ...utils.filelock import AsyncExclusiveFileLock, LockTimeout
|
||||||
|
@ -58,7 +59,8 @@ def get_deploy_class(
|
||||||
_deployers = {
|
_deployers = {
|
||||||
AppType.WEB: ZipDeploy,
|
AppType.WEB: ZipDeploy,
|
||||||
AppType.GIT_REPO: GitDeploy,
|
AppType.GIT_REPO: GitDeploy,
|
||||||
AppType.ZIP: ZipDeploy
|
AppType.ZIP: ZipDeploy,
|
||||||
|
AppType.PYTHON: PythonDeploy
|
||||||
}
|
}
|
||||||
return _deployers.get(key, default)
|
return _deployers.get(key, default)
|
||||||
|
|
||||||
|
@ -209,7 +211,7 @@ class UpdateManager:
|
||||||
kpath: str = kinfo['klipper_path']
|
kpath: str = kinfo['klipper_path']
|
||||||
executable: str = kinfo['python_path']
|
executable: str = kinfo['python_path']
|
||||||
kupdater = self.updaters.get('klipper')
|
kupdater = self.updaters.get('klipper')
|
||||||
app_type = get_app_type(kpath)
|
app_type = AppType.detect(kpath)
|
||||||
if (
|
if (
|
||||||
(isinstance(kupdater, AppDeploy) and
|
(isinstance(kupdater, AppDeploy) and
|
||||||
kupdater.check_same_paths(kpath, executable)) or
|
kupdater.check_same_paths(kpath, executable)) or
|
||||||
|
|
Loading…
Reference in New Issue