Cleanup package installation code

This commit is contained in:
Disassembler 2019-02-19 21:06:47 +01:00
parent c8502b2e3f
commit 9e928a4c58
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
4 changed files with 9 additions and 9 deletions

View File

@ -71,7 +71,7 @@ class AppMgr:
item.data = math.floor(int(progress[0]) / int(progress[1]) * 100) item.data = math.floor(int(progress[0]) / int(progress[1]) * 100)
# If the apk command didn't finish with returncode 0, raise an exception # If the apk command didn't finish with returncode 0, raise an exception
if p.returncode: if p.returncode:
raise CalledProcessError(p.returncode, cmd) raise subprocess.CalledProcessError(p.returncode, p.args)
def uninstall_app(self, item): def uninstall_app(self, item):
# Main uninstallation function. Wrapper for uninstallation via native package manager # Main uninstallation function. Wrapper for uninstallation via native package manager

View File

@ -27,18 +27,19 @@ class VMMgr:
'login': login if login else 'N/A', 'login': login if login else 'N/A',
'password': password if password else 'N/A', 'password': password if password else 'N/A',
'visible': False} 'visible': False}
self.save_and_reload_config() self.conf.save()
self.reload_wsgi_config()
def unregister_app(self, app): def unregister_app(self, app):
# Unregister application during uninstallation (called at the end of package uninstall.sh) # Unregister application during uninstallation (called at the end of package uninstall.sh)
if app not in self.conf['apps']: if app not in self.conf['apps']:
return return
del self.conf['apps'][app] del self.conf['apps'][app]
self.save_and_reload_config()
def reload_config(self):
# Attempt to contact running vmmgr WSGI application to reload config
self.conf.save() self.conf.save()
self.reload_wsgi_config()
def reload_wsgi_config(self):
# Attempt to contact running vmmgr WSGI application to reload config
try: try:
requests.get('http://127.0.0.1:8080/reload-config', timeout=3) requests.get('http://127.0.0.1:8080/reload-config', timeout=3)
except: except:

View File

@ -204,13 +204,13 @@ class WSGIApp:
status = lang.status_stopping() status = lang.status_stopping()
elif item.action == self.appmgr.install_app: elif item.action == self.appmgr.install_app:
if not item.started: if not item.started:
status = '{} ({})'.format(lang.status_downloading(), lang.status_queued()) status = '{} ({})'.format(lang.status_installing(), lang.status_queued())
elif isinstance(item.data, BaseException): elif isinstance(item.data, BaseException):
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 < 100: if item.data < 100:
status = '{} ({} %)'.format(lang.status_downloading(), item.data) status = '{} ({} %)'.format(lang.status_installing(), item.data)
else: else:
status = lang.status_installing() status = lang.status_installing()
elif item.action == self.appmgr.uninstall_app: elif item.action == self.appmgr.uninstall_app:

View File

@ -36,7 +36,6 @@ class WSGILang:
'status_started': 'Spuštěna', 'status_started': 'Spuštěna',
'status_stopping': 'Zastavuje se', 'status_stopping': 'Zastavuje se',
'status_stopped': 'Zastavena', 'status_stopped': 'Zastavena',
'status_downloading': 'Stahuje se',
'status_installing': 'Instaluje se', 'status_installing': 'Instaluje se',
'status_uninstalling': 'Odinstalovává se', 'status_uninstalling': 'Odinstalovává se',
'status_not_installed': 'Není nainstalována', 'status_not_installed': 'Není nainstalována',