[PATCH 3/3] Make exception handling in the rescue mode work

Martin Sivak msivak at redhat.com
Fri Mar 29 10:52:53 UTC 2013


Ack.

----- Original Message -----
> There is the RescueInterface class an instance of which should be
> assigned to
> anaconda.intf as in both other cases -- tui and gui. Also the
> 'meh_interface'
> and 'tty_num' properties have to added to make RescueInterface valid
> user
> interface with exception handling support. But since RescueInterface
> uses snack,
> it unfortunately needs a special class for exception handling
> interface that
> shuts snack down before running textual exception handler.
> ---
>  anaconda             |  8 +++++---
>  pyanaconda/rescue.py | 25 ++++++++++++++++++++++---
>  2 files changed, 27 insertions(+), 6 deletions(-)
> 
> diff --git a/anaconda b/anaconda
> index 0d60c71..c6e5c92 100755
> --- a/anaconda
> +++ b/anaconda
> @@ -959,6 +959,10 @@ if __name__ == "__main__":
>      # now start the interface
>      setupDisplay(anaconda, opts, addon_paths)
>  
> +    if anaconda.rescue:
> +        from pyanaconda import rescue
> +        anaconda.intf = rescue.RescueInterface()
> +
>      # Set flag to prompt for missing ks data
>      if anaconda.displayMode == 'c':
>          flags.ksprompt = False
> @@ -1004,9 +1008,7 @@ if __name__ == "__main__":
>      from pyanaconda.network import networkInitialize,
>      wait_for_connecting_NM_thread
>  
>      if anaconda.rescue:
> -        from pyanaconda.rescue import doRescue
> -        doRescue(anaconda.rescue_mount, ksdata)
> -
> +        rescue.doRescue(anaconda.intf, anaconda.rescue_mount,
> ksdata)
>  
>      networkInitialize(ksdata)
>      if not flags.dirInstall:
> diff --git a/pyanaconda/rescue.py b/pyanaconda/rescue.py
> index c6750bf..cf3db7d 100644
> --- a/pyanaconda/rescue.py
> +++ b/pyanaconda/rescue.py
> @@ -38,6 +38,7 @@ import re
>  import network
>  import subprocess
>  from pykickstart.constants import *
> +import meh.ui.text
>  
>  import gettext
>  _ = lambda x: gettext.ldgettext("anaconda", x)
> @@ -97,6 +98,14 @@ class RescueInterface(InstallInterfaceBase):
>          w.pop()
>          return passphrase
>  
> +    @property
> +    def meh_interface(self):
> +        return self._meh_interface
> +
> +    @property
> +    def tty_num(self):
> +        return 1
> +
>      def shutdown (self):
>          self.screen.finish()
>  
> @@ -109,6 +118,18 @@ 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
>  
>  def makeFStab(instPath = ""):
>      if os.access("/proc/mounts", os.R_OK):
> @@ -191,7 +212,7 @@ def runShell(screen = None, msg=""):
>      if screen:
>          screen.finish()
>  
> -def doRescue(rescue_mount, ksdata):
> +def doRescue(intf, rescue_mount, ksdata):
>      import blivet
>  
>      for file in [ "services", "protocols", "group", "joe",
>      "man.config",
> @@ -201,8 +222,6 @@ def doRescue(rescue_mount, ksdata):
>          except OSError:
>              pass
>  
> -    intf = RescueInterface()
> -
>      # Early shell access with no disk access attempts
>      if not rescue_mount:
>          # the %post should be responsible for mounting all needed
>          file systems
> --
> 1.7.11.7
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 


More information about the anaconda-patches mailing list