Add unpack installation stage and use enum for stages
This commit is contained in:
parent
b5f8f3cf84
commit
d5cec3491b
@ -6,18 +6,21 @@ import requests
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from enum import Enum
|
||||||
from werkzeug.exceptions import BadRequest, NotFound, Unauthorized
|
from werkzeug.exceptions import BadRequest, NotFound, Unauthorized
|
||||||
|
|
||||||
from . import crypto
|
from . import crypto
|
||||||
from .paths import LXC_ROOT
|
from .paths import LXC_ROOT
|
||||||
|
|
||||||
STAGE_DOWNLOAD = 0
|
class Stage(Enum):
|
||||||
STAGE_INSTALL_DEPS = 1
|
DOWNLOAD = 1
|
||||||
STAGE_INSTALL_APP = 2
|
UNPACK = 2
|
||||||
|
INSTALL_DEPS = 3
|
||||||
|
INSTALL_APP = 4
|
||||||
|
|
||||||
class Pkg:
|
class Pkg:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.stage = STAGE_DOWNLOAD
|
self.stage = Stage.DOWNLOAD
|
||||||
self.bytes_total = 1
|
self.bytes_total = 1
|
||||||
self.bytes_downloaded = 0
|
self.bytes_downloaded = 0
|
||||||
|
|
||||||
@ -58,11 +61,13 @@ class PkgMgr:
|
|||||||
for dep in deps:
|
for dep in deps:
|
||||||
self.download_package(dep, item)
|
self.download_package(dep, item)
|
||||||
for dep in deps:
|
for dep in deps:
|
||||||
# Set stage to INSTALLING_DEPS or INSTALLING based on which package in sequence is being installed
|
|
||||||
item.stage = STAGE_INSTALL_APP if dep == deps[-1] else STAGE_INSTALL_DEPS
|
|
||||||
# Purge old data before unpacking to clean previous failed installation
|
# Purge old data before unpacking to clean previous failed installation
|
||||||
|
item.stage = Stage.UNPACK
|
||||||
self.purge_package(dep)
|
self.purge_package(dep)
|
||||||
self.unpack_package(dep)
|
self.unpack_package(dep)
|
||||||
|
for dep in deps:
|
||||||
|
# Set stage to INSTALLING_DEPS or INSTALLING based on which package in sequence is being installed
|
||||||
|
item.stage = Stage.INSTALL_APP if dep == deps[-1] else Stage.INSTALL_DEPS
|
||||||
# Run uninstall script before installation to clean previous failed installation
|
# Run uninstall script before installation to clean previous failed installation
|
||||||
self.run_uninstall_script(dep)
|
self.run_uninstall_script(dep)
|
||||||
self.run_install_script(dep)
|
self.run_install_script(dep)
|
||||||
|
@ -17,6 +17,7 @@ from . import validator
|
|||||||
from .actionqueue import ActionQueue
|
from .actionqueue import ActionQueue
|
||||||
from .appmgr import AppMgr
|
from .appmgr import AppMgr
|
||||||
from .config import Config
|
from .config import Config
|
||||||
|
from .pkgmgr import Stage
|
||||||
from .vmmgr import VMMgr
|
from .vmmgr import VMMgr
|
||||||
from .wsgilang import WSGILang
|
from .wsgilang import WSGILang
|
||||||
from .wsgisession import WSGISession
|
from .wsgisession import WSGISession
|
||||||
@ -182,7 +183,7 @@ class WSGIApp:
|
|||||||
actionable_apps = sorted(set([k for k, v in online_packages.items() if 'title' in v] + list(self.conf['apps'].keys())))
|
actionable_apps = sorted(set([k for k, v in online_packages.items() if 'title' in v] + list(self.conf['apps'].keys())))
|
||||||
app_data = {}
|
app_data = {}
|
||||||
for app in actionable_apps:
|
for app in actionable_apps:
|
||||||
installed = app in self.conf['packages']
|
installed = app in self.conf['packages'] and app in self.conf['apps']
|
||||||
title = self.conf['packages'][app]['title'] if installed else online_packages[app]['title']
|
title = self.conf['packages'][app]['title'] if installed else online_packages[app]['title']
|
||||||
visible = self.conf['apps'][app]['visible'] if installed else False
|
visible = self.conf['apps'][app]['visible'] if installed else False
|
||||||
autostarted = self.appmgr.is_service_autostarted(app) if installed else False
|
autostarted = self.appmgr.is_service_autostarted(app) if installed else False
|
||||||
@ -218,9 +219,11 @@ class WSGIApp:
|
|||||||
status = '<span class="error">{}</span> <a href="#" class="app-clear-status">OK</a>'.format(lang.package_manager_error())
|
status = '<span class="error">{}</span> <a href="#" class="app-clear-status">OK</a>'.format(lang.package_manager_error())
|
||||||
actions = None
|
actions = None
|
||||||
else:
|
else:
|
||||||
if item.data.stage == 0:
|
if item.data.stage == Stage.DOWNLOAD:
|
||||||
status = '{} ({} %)'.format(lang.status_downloading(), item.data.percent_downloaded)
|
status = '{} ({} %)'.format(lang.status_downloading(), item.data.percent_downloaded)
|
||||||
elif item.data.stage == 1:
|
elif item.data.stage == Stage.UNPACK:
|
||||||
|
status = lang.status_unpacking()
|
||||||
|
elif item.data.stage == Stage.INSTALL_DEPS:
|
||||||
status = lang.status_installing_deps()
|
status = lang.status_installing_deps()
|
||||||
else:
|
else:
|
||||||
status = lang.status_installing()
|
status = lang.status_installing()
|
||||||
|
@ -40,6 +40,7 @@ class WSGILang:
|
|||||||
'status_stopping': 'Zastavuje se',
|
'status_stopping': 'Zastavuje se',
|
||||||
'status_stopped': 'Zastavena',
|
'status_stopped': 'Zastavena',
|
||||||
'status_downloading': 'Stahuje se',
|
'status_downloading': 'Stahuje se',
|
||||||
|
'status_unpacking': 'Rozbaluje se',
|
||||||
'status_installing': 'Instaluje se',
|
'status_installing': 'Instaluje se',
|
||||||
'status_installing_deps': 'Instalují se závislosti',
|
'status_installing_deps': 'Instalují se závislosti',
|
||||||
'status_uninstalling': 'Odinstalovává se',
|
'status_uninstalling': 'Odinstalovává se',
|
||||||
|
Loading…
Reference in New Issue
Block a user