Esempio n. 1
0
    def runDebug(self, exc_info):
        if conf.system.can_switch_tty and self._intf_tty_num != 1:
            util.vtActivate(1)

        os.open("/dev/console", os.O_RDWR)  # reclaim stdin
        os.dup2(0, 1)  # reclaim stdout
        os.dup2(0, 2)  # reclaim stderr
        #   ^
        #   |
        #   +------ dup2 is magic, I tells ya!

        # bring back the echo
        import termios
        si = sys.stdin.fileno()
        attr = termios.tcgetattr(si)
        attr[3] = attr[3] & termios.ECHO
        termios.tcsetattr(si, termios.TCSADRAIN, attr)

        print("\nEntering debugger...")
        print(
            "Use 'continue' command to quit the debugger and get back to the main window"
        )
        import pdb
        pdb.post_mortem(exc_info.stack)

        if conf.system.can_switch_tty and self._intf_tty_num != 1:
            util.vtActivate(self._intf_tty_num)
Esempio n. 2
0
    def runDebug(self, exc_info):
        if conf.system.can_switch_tty and self._intf_tty_num != 1:
            util.vtActivate(1)

        os.open("/dev/console", os.O_RDWR)   # reclaim stdin
        os.dup2(0, 1)                        # reclaim stdout
        os.dup2(0, 2)                        # reclaim stderr
        #   ^
        #   |
        #   +------ dup2 is magic, I tells ya!

        # bring back the echo
        import termios
        si = sys.stdin.fileno()
        attr = termios.tcgetattr(si)
        attr[3] = attr[3] & termios.ECHO
        termios.tcsetattr(si, termios.TCSADRAIN, attr)

        print("\nEntering debugger...")
        print("Use 'continue' command to quit the debugger and get back to the main window")
        import pdb
        pdb.post_mortem(exc_info.stack)

        if conf.system.can_switch_tty and self._intf_tty_num != 1:
            util.vtActivate(self._intf_tty_num)
Esempio n. 3
0
    def test_vt_activate(self):
        """Test vtActivate."""

        # pylint: disable=no-member

        def raise_os_error(*args, **kwargs):
            raise OSError

        _execWithRedirect = util.vtActivate.__globals__['execWithRedirect']

        try:
            # chvt does not exist on all platforms
            # and the function needs to correctly survie that
            util.vtActivate.__globals__['execWithRedirect'] = raise_os_error

            assert util.vtActivate(2) is False
        finally:
            util.vtActivate.__globals__['execWithRedirect'] = _execWithRedirect
Esempio n. 4
0
    def vt_activate_test(self):
        """Test vtActivate."""

        # pylint: disable=no-member

        def raise_os_error(*args, **kwargs):
            raise OSError

        _execWithRedirect = util.vtActivate.__globals__['execWithRedirect']

        try:
            # chvt does not exist on all platforms
            # and the function needs to correctly survie that
            util.vtActivate.__globals__['execWithRedirect'] = raise_os_error

            self.assertEqual(util.vtActivate(2), False)
        finally:
            util.vtActivate.__globals__['execWithRedirect'] = _execWithRedirect
Esempio n. 5
0
 def _earlyExceptionHandler(ty, value, traceback):
     util.ipmi_report(constants.IPMI_FAILED)
     util.vtActivate(1)
     return sys.__excepthook__(ty, value, traceback)
Esempio n. 6
0
 def _earlyExceptionHandler(ty, value, traceback):
     util.ipmi_report(constants.IPMI_FAILED)
     util.vtActivate(1)
     return sys.__excepthook__(ty, value, traceback)
Esempio n. 7
0
def setup_display(anaconda, options):
    """Setup the display for the installation environment.

    :param anaconda: instance of the Anaconda class
    :param options: command line/boot options
    """

    try:
        xtimeout = int(options.xtimeout)
    except ValueError:
        log.warning("invalid inst.xtimeout option value: %s", options.xtimeout)
        xtimeout = constants.X_TIMEOUT

    vnc_server = vnc.VncServer()  # The vnc Server object.
    vnc_server.anaconda = anaconda
    vnc_server.timeout = xtimeout

    anaconda.display_mode = options.display_mode
    anaconda.interactive_mode = not options.noninteractive

    if options.vnc:
        flags.usevnc = True
        if not anaconda.gui_mode:
            log.info(
                "VNC requested via boot/CLI option, switching Anaconda to GUI mode."
            )
            anaconda.display_mode = constants.DisplayModes.GUI
        vnc_server.password = options.vncpassword

        # Only consider vncconnect when vnc is a param
        if options.vncconnect:
            cargs = options.vncconnect.split(":")
            vnc_server.vncconnecthost = cargs[0]
            if len(cargs) > 1 and len(cargs[1]) > 0:
                if len(cargs[1]) > 0:
                    vnc_server.vncconnectport = cargs[1]

    if options.xdriver:
        write_xdriver(options.xdriver, root="/")

    if flags.rescue_mode:
        return

    if anaconda.ksdata.vnc.enabled:
        flags.usevnc = True
        if not anaconda.gui_mode:
            log.info(
                "VNC requested via kickstart, switching Anaconda to GUI mode.")
            anaconda.display_mode = constants.DisplayModes.GUI

        if vnc_server.password == "":
            vnc_server.password = anaconda.ksdata.vnc.password

        if vnc_server.vncconnecthost == "":
            vnc_server.vncconnecthost = anaconda.ksdata.vnc.host

        if vnc_server.vncconnectport == "":
            vnc_server.vncconnectport = anaconda.ksdata.vnc.port

    if anaconda.gui_mode:
        mods = (tup[1] for tup in pkgutil.iter_modules(pyanaconda.ui.__path__,
                                                       "pyanaconda.ui."))
        if "pyanaconda.ui.gui" not in mods:
            stdout_log.warning(
                "Graphical user interface not available, falling back to text mode"
            )
            anaconda.display_mode = constants.DisplayModes.TUI
            flags.usevnc = False
            flags.vncquestion = False

    # check if VNC can be started
    vnc_can_be_started, vnc_error_messages = check_vnc_can_be_started(anaconda)
    if not vnc_can_be_started:
        # VNC can't be started - disable the VNC question and log
        # all the errors that prevented VNC from being started
        flags.vncquestion = False
        for error_message in vnc_error_messages:
            stdout_log.warning(error_message)

    # Should we try to start Xorg?
    want_x = anaconda.gui_mode and not (flags.preexisting_x11 or flags.usevnc)

    # Is Xorg is actually available?
    if want_x and not os.access("/usr/bin/Xorg", os.X_OK):
        stdout_log.warning(
            _("Graphical installation is not available. "
              "Starting text mode."))
        time.sleep(2)
        anaconda.display_mode = constants.DisplayModes.TUI
        want_x = False

    if anaconda.tui_mode and flags.vncquestion:
        # we prefer vnc over text mode, so ask about that
        message = _("Text mode provides a limited set of installation "
                    "options. It does not offer custom partitioning for "
                    "full control over the disk layout. Would you like "
                    "to use VNC mode instead?")
        ask_vnc_question(anaconda, vnc_server, message)
        if not anaconda.ksdata.vnc.enabled:
            # user has explicitly specified text mode
            flags.vncquestion = False

    anaconda.log_display_mode()
    startup_utils.check_memory(anaconda, options)

    # check_memory may have changed the display mode
    want_x = want_x and (anaconda.gui_mode)
    if want_x:
        try:
            start_x11(xtimeout)
            do_startup_x11_actions()
        except TimeoutError as e:
            log.warning("X startup failed: %s", e)
            print(
                "\nX did not start in the expected time, falling back to text mode. There are "
                "multiple ways to avoid this issue:")
            wrapper = textwrap.TextWrapper(
                initial_indent=" * ",
                subsequent_indent="   ",
                width=os.get_terminal_size().columns - 3)
            for line in X_TIMEOUT_ADVICE.split("\n"):
                print(wrapper.fill(line))
            util.vtActivate(1)
            anaconda.display_mode = constants.DisplayModes.TUI
            anaconda.gui_startup_failed = True
            time.sleep(2)

        except (OSError, RuntimeError) as e:
            log.warning("X or window manager startup failed: %s", e)
            print(
                "\nX or window manager startup failed, falling back to text mode."
            )
            util.vtActivate(1)
            anaconda.display_mode = constants.DisplayModes.TUI
            anaconda.gui_startup_failed = True
            time.sleep(2)

        if not anaconda.gui_startup_failed:
            do_extra_x11_actions(options.runres, gui_mode=anaconda.gui_mode)

    if anaconda.tui_mode and anaconda.gui_startup_failed and flags.vncquestion and not anaconda.ksdata.vnc.enabled:
        message = _(
            "X was unable to start on your machine. Would you like to start VNC to connect to "
            "this computer from another computer and perform a graphical installation or continue "
            "with a text mode installation?")
        ask_vnc_question(anaconda, vnc_server, message)

    # if they want us to use VNC do that now
    if anaconda.gui_mode and flags.usevnc:
        vnc_server.startServer()
        do_startup_x11_actions()

    # with X running we can initialize the UI interface
    anaconda.initInterface()