[master][PATCH] Fix exception handling in rescue mode
Vratislav Podzimek
vpodzime at redhat.com
Thu Apr 18 12:29:23 UTC 2013
The old code didn't work properly because __getattr__ was never called. This
replacement is a bit more straightforward and should work.
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
---
pyanaconda/rescue.py | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
index ad8da43..b611e7f 100644
--- a/pyanaconda/rescue.py
+++ b/pyanaconda/rescue.py
@@ -118,18 +118,7 @@ class RescueInterface(InstallInterfaceBase):
def __init__(self):
InstallInterfaceBase.__init__(self)
self.screen = SnackScreen()
- self._meh_interface = RescueExceptionHandlingIface(self.screen)
-
-class RescueExceptionHandlingIface(meh.ui.text.TextIntf):
- def __init__(self, snack_screen, *args, **kwargs):
- meh.ui.text.TextIntf.__init__(self, *args, **kwargs)
- self._snack_running = True
- self._snack_screen = snack_screen
-
- def __getattr__(self, attr):
- if self._snack_running:
- self._snack_screen.finish()
- self._snack_running = False
+ self._meh_interface = meh.ui.text.TextIntf()
def makeFStab(instPath = ""):
if os.access("/proc/mounts", os.R_OK):
@@ -212,9 +201,30 @@ def runShell(screen = None, msg=""):
if screen:
screen.finish()
+def _exception_handler_wrapper(orig_except_handler, screen, *args):
+ """
+ Helper function that wraps the exception handler with snack shutdown.
+
+ :param orig_except_handler: original exception handler that should be run
+ after the wrapping changes are done
+ :type orig_except_handler: exception handler as can be set as sys.excepthook
+ :param screen: snack screen that should be shut down before further actions
+ :type screen: snack screen
+
+ """
+
+ screen.finish()
+ return orig_except_handler(*args)
+
def doRescue(intf, rescue_mount, ksdata):
import blivet
+ # XXX: hook the exception handler wrapper that turns off snack first
+ orig_hook = sys.excepthook
+ sys.excepthook = lambda ty, val, tb: _exception_handler_wrapper(orig_hook,
+ intf.screen,
+ ty, val, tb)
+
for file in [ "services", "protocols", "group", "joe", "man.config",
"nsswitch.conf", "selinux", "mke2fs.conf" ]:
try:
--
1.7.11.7
More information about the anaconda-patches
mailing list