###############################################################################
import logging
+import sys
+import traceback
from . import disk
from . import lang
from . import logger
from . import step
from . import tui
+from .i18n import _
+from .errors import *
# Setup logging
log = logging.getLogger("bricklayer")
with self.tui:
# Walk through all steps
for step in self.steps:
- self._run_step(step)
+ try:
+ self._run_step(step)
+
+ # End installer if aborted
+ except InstallAbortedError:
+ return 1
+
+ # Catch all other exceptions and show an error
+ except:
+ type, value, tb = sys.exc_info()
+
+ # Log the error
+ log.error("An unexpected error occured:", exc_info=True)
+
+ # Format the exception
+ error = _("The installation cannot be continued due to an error:"
+ "\n\n%s") % "".join(traceback.format_exception(type, value, tb))
+
+ # Show an error message
+ self.tui.error(_("An Unexpected Error Occured"),
+ "".join(error), buttons=[_("Exit")], width=60)
+
+ # Exit
+ return 1
def _run_step(self, stepcls):
"""
self.screen.pushHelpLine(helpline)
- def message(self, title, text, buttons=None, help=None):
+ def message(self, title, text, buttons=None, help=None, width=40):
"""
Shows a message to the user
"""
buttons = (_("OK"), _("Cancel"))
return snack.ButtonChoiceWindow(self.screen, title=title, text=text,
- buttons=buttons, help=help)
+ buttons=buttons, width=width, help=help)
- def error(self, title, text, buttons=None):
+ def error(self, title, text, buttons=None, width=40):
if not buttons:
buttons = [_("Abort Installation")]
- return self.message(title, text, buttons=buttons)
+ return self.message(title, text, buttons=buttons, width=width)
def progress(self, *args, **kwargs):
return ProgressWindow(self, *args, **kwargs)