mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
setup: Implement operation to uninstall an app
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
a1c6c7b6a7
commit
811e95f561
@ -92,6 +92,50 @@ def _run_setup_on_app(app, current_version):
|
||||
operation.on_update(message, exception_to_update)
|
||||
|
||||
|
||||
def run_uninstall_on_app(app_id):
|
||||
"""Execute the uninstall process in a thread."""
|
||||
# App is already uninstalled
|
||||
app = app_module.App.get(app_id)
|
||||
if not app.get_setup_version():
|
||||
return
|
||||
|
||||
logger.debug('Creating operation to uninstall app: %s', app_id)
|
||||
return operation_module.manager.new(app_id,
|
||||
gettext_noop('Uninstalling app'),
|
||||
_run_uninstall_on_app, [app],
|
||||
show_notification=True)
|
||||
|
||||
|
||||
def _run_uninstall_on_app(app):
|
||||
"""Execute the uninstall process."""
|
||||
logger.info('Uninstall run: %s', app.app_id)
|
||||
exception_to_update = None
|
||||
message = None
|
||||
try:
|
||||
app.disable()
|
||||
app.uninstall()
|
||||
app.set_setup_version(0)
|
||||
except PackageException as exception:
|
||||
exception_to_update = exception
|
||||
error_string = getattr(exception, 'error_string', str(exception))
|
||||
error_details = getattr(exception, 'error_details', '')
|
||||
message = gettext_noop('Error uninstalling app: {string} '
|
||||
'{details}').format(string=error_string,
|
||||
details=error_details)
|
||||
|
||||
except Exception as exception:
|
||||
exception_to_update = exception
|
||||
message = gettext_noop('Error uninstalling app: {error}').format(
|
||||
error=exception)
|
||||
else:
|
||||
message = gettext_noop('App uninstalled.')
|
||||
|
||||
logger.info('Uninstall completed: %s: %s %s', app.app_id, message,
|
||||
exception_to_update)
|
||||
operation = operation_module.Operation.get_operation()
|
||||
operation.on_update(message, exception_to_update)
|
||||
|
||||
|
||||
def stop():
|
||||
"""Set a flag to indicate that the setup process must stop."""
|
||||
global _is_shutting_down
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user