From 5ba5461a80781cfa3c99e4852eb07016764424a0 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Wed, 31 Oct 2018 07:42:38 +0100 Subject: [PATCH] Add unpacking stage to AppMgr installation --- basic/srv/vm/mgr/appmgr.py | 14 ++++++++++---- basic/srv/vm/mgr/wsgiapp.py | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/basic/srv/vm/mgr/appmgr.py b/basic/srv/vm/mgr/appmgr.py index 1d7750c..289dd44 100644 --- a/basic/srv/vm/mgr/appmgr.py +++ b/basic/srv/vm/mgr/appmgr.py @@ -32,7 +32,7 @@ class ActionItem: class InstallItem: def __init__(self, total): - # Stage 0 = download, 1 = deps install, 2 = app install + # Stage 0 = download, 1 = unpack, 2 = deps install, 3 = app install self.stage = 0 self.total = total self.downloaded = 0 @@ -108,9 +108,13 @@ class AppMgr: for dep in deps: self.download_package(dep, item.data) for dep in deps: - item.data.stage = 2 if dep == deps[-1] else 1 + item.data.stage = 1 + # Purge old data before unpacking to clean previous failed installation + self.purge_package() self.unpack_package(dep) - # Run uninstall script before installation to purge previous failed installation + for deps in deps: + item.data.stage = 3 if dep == deps[-1] else 2 + # Run uninstall script before installation to clean previous failed installation self.run_uninstall_script(dep) self.register_package(dep) self.run_install_script(dep) @@ -143,7 +147,9 @@ class AppMgr: def purge_package(self, name): # Removes package and shared data from filesystem - shutil.rmtree(os.path.join(LXC_ROOT, self.conf['packages'][name]['lxcpath'])) + lxc_dir = os.path.join(LXC_ROOT, self.conf['packages'][name]['lxcpath']) + if os.path.exists(lxc_dir): + shutil.rmtree(lxc_dir) srv_dir = os.path.join('/srv/', name) if os.path.exists(srv_dir): shutil.rmtree(srv_dir) diff --git a/basic/srv/vm/mgr/wsgiapp.py b/basic/srv/vm/mgr/wsgiapp.py index 97f706e..faee738 100644 --- a/basic/srv/vm/mgr/wsgiapp.py +++ b/basic/srv/vm/mgr/wsgiapp.py @@ -184,6 +184,8 @@ class WSGIApp(object): if item.data.stage == 0: status = 'Stahuje se ({} %)'.format(item.data) elif item.data.stage == 1: + status = 'Rozbaluje se' + elif item.data.stage == 2: status = 'Instalují se závislosti' else: status = 'Instaluje se'