Display install_app exceptions raised during action queuing

This commit is contained in:
Disassembler 2020-04-04 13:38:57 +02:00
parent 571e641787
commit 5265b31504
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499

View File

@ -199,46 +199,45 @@ class WSGIApp:
if app in pending_actions: if app in pending_actions:
# Display queued or currently processed actions # Display queued or currently processed actions
app_queue = pending_actions[app] app_queue = pending_actions[app]
if app_queue.index: if app_queue.exception:
if app_queue.exception: # Display failed task
# Display failed task if isinstance(app_queue.exception, InvalidSignature):
if isinstance(app_queue.exception, InvalidSignature): status = lang.repo_package_invalid_signature()
status = lang.repo_package_invalid_signature() elif isinstance(app_queue.exception, NotFound):
elif isinstance(app_queue.exception, NotFound): status = lang.repo_package_missing()
status = lang.repo_package_missing() elif isinstance(app_queue.exception, BaseException):
elif isinstance(app_queue.exception, BaseException): if app_queue.action in (vmmgr.start_app, vmmgr.stop_app):
if app_queue.action in (vmmgr.start_app, vmmgr.stop_app): status = lang.stop_start_error()
status = lang.stop_start_error() else:
else: status = lang.package_manager_error()
status = lang.package_manager_error() status = f'<span class="error">{status}<span> <a href="#" class="app-clear-status">OK</a>'
status = f'<span class="error">{status}<span> <a href="#" class="app-clear-status">OK</a>' actions = None
actions = None elif app_queue.index:
else: # Display task/subtask progress
# Display task/subtask progress action_item = app_queue.queue[app_queue.index-1]
action_item = app_queue.queue[app_queue.index-1] if action_item.type in (ActionItemType.IMAGE_DOWNLOAD, ActionItemType.APP_DOWNLOAD):
if action_item.type in (ActionItemType.IMAGE_DOWNLOAD, ActionItemType.APP_DOWNLOAD): status = lang.status_downloading(action_item.key)
status = lang.status_downloading(action_item.key) elif action_item.type in (ActionItemType.IMAGE_UNPACK, ActionItemType.APP_UNPACK):
elif action_item.type in (ActionItemType.IMAGE_UNPACK, ActionItemType.APP_UNPACK): status = lang.status_unpacking(action_item.key)
status = lang.status_unpacking(action_item.key) elif action_item.type == ActionItemType.IMAGE_DELETE:
elif action_item.type == ActionItemType.IMAGE_DELETE: status = lang.status_deleting(action_item.key)
status = lang.status_deleting(action_item.key) elif action_item.type == ActionItemType.APP_START:
elif action_item.type == ActionItemType.APP_START: status = lang.status_starting()
status = lang.status_starting() elif action_item.type == ActionItemType.APP_STOP:
elif action_item.type == ActionItemType.APP_STOP: status = lang.status_stopping()
status = lang.status_stopping() elif action_item.type == ActionItemType.APP_INSTALL:
elif action_item.type == ActionItemType.APP_INSTALL: status = lang.status_installing()
status = lang.status_installing() elif action_item.type == ActionItemType.APP_UPDATE:
elif action_item.type == ActionItemType.APP_UPDATE: status = lang.status_updating()
status = lang.status_updating() elif action_item.type == ActionItemType.APP_UNINSTALL:
elif action_item.type == ActionItemType.APP_UNINSTALL: status = lang.status_uninstalling()
status = lang.status_uninstalling() if app_queue.action not in (vmmgr.start_app, vmmgr.stop_app):
if app_queue.action not in (vmmgr.start_app, vmmgr.stop_app): # For tasks other than start/stop which have only a single subtask, display also index of the subtask in queue
# For tasks other than start/stop which have only a single subtask, display also index of the subtask in queue status = f'[{app_queue.index}/{len(app_queue.queue)}] {status}'
status = f'[{app_queue.index}/{len(app_queue.queue)}] {status}' if action_item.units_total:
if action_item.units_total: # Show progress for tasks which have measurable progress
# Show progress for tasks which have measurable progress status = f'{status} ({floor(action_item.units_done/action_item.units_total*100)} %)'
status = f'{status} ({floor(action_item.units_done/action_item.units_total*100)} %)' actions = '<div class="loader"></div>'
actions = '<div class="loader"></div>'
else: else:
# Display queued (pending, not started) task # Display queued (pending, not started) task
if app_queue.action == vmmgr.start_app: if app_queue.action == vmmgr.start_app: