From ade2d0c8f2dc04e30c3e4ad52ffde4bfa3c34d33 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 11 Mar 2024 15:00:21 -0700 Subject: [PATCH] package: Drop special error message handling for package errors - We have new way to show extra details with exceptions in HTML. - This handling of error details in PackageException is mostly unused and unnecessary complexity. Tests: - Introduce exception into package.install() and package.uninstall() methods. Test that exceptions are being shown properly in Django error messages. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/package.py | 12 ------------ plinth/setup.py | 22 +--------------------- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/plinth/package.py b/plinth/package.py index 94ff19ee8..17274eacb 100644 --- a/plinth/package.py +++ b/plinth/package.py @@ -275,18 +275,6 @@ class Packages(app_module.FollowerComponent): class PackageException(Exception): """A package operation has failed.""" - def __init__(self, error_string=None, error_details=None, *args, **kwargs): - """Store apt-get error string and details.""" - super().__init__(*args, **kwargs) - - self.error_string = error_string - self.error_details = error_details - - def __str__(self): - """Return the strin representation of the exception.""" - return 'PackageException(error_string="{0}", error_details="{1}")' \ - .format(self.error_string, self.error_details) - class Transaction: """Information about an ongoing transaction.""" diff --git a/plinth/setup.py b/plinth/setup.py index edf9e54f9..12729e519 100644 --- a/plinth/setup.py +++ b/plinth/setup.py @@ -13,7 +13,7 @@ from django.utils.translation import gettext_noop import plinth from plinth import app as app_module -from plinth.package import PackageException, Packages +from plinth.package import Packages from plinth.signals import post_setup from . import operation as operation_module @@ -69,18 +69,6 @@ def _run_setup_on_app(app, current_version): app.setup(old_version=current_version) app.set_setup_version(app.info.version) post_setup.send_robust(sender=app.__class__, module_name=app.app_id) - except PackageException as exception: - exception_to_update = exception - error_string = getattr(exception, 'error_string', str(exception)) - error_details = getattr(exception, 'error_details', '') - if not current_version: - message = gettext_noop('Error installing app: {string} ' - '{details}').format(string=error_string, - details=error_details) - else: - message = gettext_noop('Error updating app: {string} ' - '{details}').format(string=error_string, - details=error_details) except Exception as exception: exception_to_update = exception if not current_version: @@ -124,14 +112,6 @@ def _run_uninstall_on_app(app): 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(