mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
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 <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
28e417d7ef
commit
ade2d0c8f2
@ -275,18 +275,6 @@ class Packages(app_module.FollowerComponent):
|
|||||||
class PackageException(Exception):
|
class PackageException(Exception):
|
||||||
"""A package operation has failed."""
|
"""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:
|
class Transaction:
|
||||||
"""Information about an ongoing transaction."""
|
"""Information about an ongoing transaction."""
|
||||||
|
|||||||
@ -13,7 +13,7 @@ from django.utils.translation import gettext_noop
|
|||||||
|
|
||||||
import plinth
|
import plinth
|
||||||
from plinth import app as app_module
|
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 plinth.signals import post_setup
|
||||||
|
|
||||||
from . import operation as operation_module
|
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.setup(old_version=current_version)
|
||||||
app.set_setup_version(app.info.version)
|
app.set_setup_version(app.info.version)
|
||||||
post_setup.send_robust(sender=app.__class__, module_name=app.app_id)
|
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:
|
except Exception as exception:
|
||||||
exception_to_update = exception
|
exception_to_update = exception
|
||||||
if not current_version:
|
if not current_version:
|
||||||
@ -124,14 +112,6 @@ def _run_uninstall_on_app(app):
|
|||||||
app.disable()
|
app.disable()
|
||||||
app.uninstall()
|
app.uninstall()
|
||||||
app.set_setup_version(0)
|
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:
|
except Exception as exception:
|
||||||
exception_to_update = exception
|
exception_to_update = exception
|
||||||
message = gettext_noop('Error uninstalling app: {error}').format(
|
message = gettext_noop('Error uninstalling app: {error}').format(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user