示例#1
0
def start_rescue_mode_ui(anaconda):
    """Start the rescue mode UI."""

    ksdata_rescue = None
    if anaconda.ksdata.rescue.seen:
        ksdata_rescue = anaconda.ksdata.rescue
    scripts = anaconda.ksdata.scripts
    storage = anaconda.storage
    reboot = True
    if conf.target.is_image:
        reboot = False
    if flags.automatedInstall and anaconda.ksdata.reboot.action not in [KS_REBOOT, KS_SHUTDOWN]:
        reboot = False

    rescue = Rescue(storage, ksdata_rescue, reboot, scripts)
    rescue.initialize()

    # We still want to choose from multiple roots, or unlock encrypted devices
    # if needed, so we run UI even for kickstarts (automated install).
    App.initialize()
    loop = App.get_event_loop()
    loop.set_quit_callback(tui_quit_callback)
    spoke = RescueModeSpoke(rescue)
    ScreenHandler.schedule_screen(spoke)
    App.run()
    def test_blocking_input(self, mock_stdin, mock_stdout):
        prompt_message = "test prompt"
        ret = "blocking test"
        mock_stdin.return_value = ret
        screen = BlockingInputTestScreen(prompt_message, False)

        App.get_scheduler().schedule_screen(screen)
        App.run()

        self.assertEqual(screen.input_returned, ret)

        out = mock_stdout.getvalue()
        out = out.split("\n")[-1].strip()
        self.assertEqual(out, prompt_message)
示例#3
0
    def test_widget_too_high(self, out_mock, in_mock):
        in_mock.return_value = "\n"
        in_mock.side_effect = lambda: print('\n')

        widget_text = ("Line\n" "Line2\n" "Line3\n" "Line4\n" "Line5")
        # Screen height take into account also 2 lines for prompt
        screen = ScreenWithWidget(widget_text, height=6)

        App.initialize()
        App.get_scheduler().schedule_screen(screen)
        App.run()

        self.assertEqual(self._expected_output(widget_text, widget_height=6),
                         out_mock.getvalue())
    def test_blocking_password_input(self, mock_getpass, mock_stdin,
                                     mock_stdout):
        prompt_message = "test prompt"
        ret = "blocking test"
        mock_getpass.return_value = ret
        screen = BlockingInputTestScreenMock(prompt_message, True)

        App.get_scheduler().schedule_screen(screen)
        App.run()

        self.assertEqual(screen.input_returned, ret)

        out = mock_stdout.getvalue()
        # can't check for prompt because that is printed by getpass func which is mocked
        self.assertGreater(len(out), 1)
示例#5
0
    def run(self):
        """Run the interface.

        This should do little more than just pass through to something else's run method,
        but is provided here in case more is needed.  This method must be provided by all subclasses.
        """
        return App.run()
示例#6
0
    def run(self):
        """Run the interface.

        This should do little more than just pass through to something else's run method,
        but is provided here in case more is needed.  This method must be provided by all subclasses.
        """
        return App.run()
示例#7
0
文件: vnc.py 项目: jaymzh/anaconda
    def changeVNCPasswdWindow(self):
        """ Change the password to a sane parameter.

        We ask user to input a password that (len(password) > 6
        and len(password) <= 8) or password == ''.
        """

        message = _("VNC password must be six to eight characters long.\n"
                    "Please enter a new one, or leave blank for no password.")
        App.initialize()
        loop = App.get_event_loop()
        loop.set_quit_callback(tui_quit_callback)
        spoke = VNCPassSpoke(self.anaconda.ksdata, None, None, None, message)
        ScreenHandler.schedule_screen(spoke)
        App.run()

        self.password = self.anaconda.ksdata.vnc.password
示例#8
0
    def changeVNCPasswdWindow(self):
        """ Change the password to a sane parameter.

        We ask user to input a password that (len(password) > 6
        and len(password) <= 8) or password == ''.
        """

        message = _("VNC password must be six to eight characters long.\n"
                    "Please enter a new one, or leave blank for no password.")
        App.initialize()
        loop = App.get_event_loop()
        loop.set_quit_callback(tui_quit_callback)
        spoke = VNCPassSpoke(self.anaconda.ksdata, None, None, message)
        ScreenHandler.schedule_screen(spoke)
        App.run()

        self.password = self.anaconda.ksdata.vnc.password
示例#9
0
def ask_vnc_question(anaconda, vnc_server, message):
    """ Ask the user if TUI or GUI-over-VNC should be started.

    :param anaconda: instance of the Anaconda class
    :param vnc_server: instance of the VNC server object
    :param str message: a message to show to the user together
                        with the question
    """
    App.initialize()
    loop = App.get_event_loop()
    loop.set_quit_callback(tui_quit_callback)
    spoke = AskVNCSpoke(anaconda.ksdata, message)
    ScreenHandler.schedule_screen(spoke)
    App.run()

    if anaconda.ksdata.vnc.enabled:
        if not anaconda.gui_mode:
            log.info("VNC requested via VNC question, switching Anaconda to GUI mode.")
        anaconda.display_mode = constants.DisplayModes.GUI
        flags.usevnc = True
        vnc_server.password = anaconda.ksdata.vnc.password
示例#10
0
def ask_vnc_question(anaconda, vnc_server, message):
    """ Ask the user if TUI or GUI-over-VNC should be started.

    :param anaconda: instance of the Anaconda class
    :param vnc_server: instance of the VNC server object
    :param str message: a message to show to the user together
                        with the question
    """
    App.initialize()
    loop = App.get_event_loop()
    loop.set_quit_callback(tui_quit_callback)
    spoke = AskVNCSpoke(anaconda.ksdata, message)
    ScreenHandler.schedule_screen(spoke)
    App.run()

    if anaconda.ksdata.vnc.enabled:
        if not anaconda.gui_mode:
            log.info("VNC requested via VNC question, switching Anaconda to GUI mode.")
        anaconda.display_mode = constants.DisplayModes.GUI
        flags.usevnc = True
        vnc_server.password = anaconda.ksdata.vnc.password
示例#11
0
            # input is then required from the user.
            if num2 == 0:
                return InputState.DISCARDED

            self._message = int(num1 / num2)

            # Because this input is processed we need to show this screen (show the result).
            # This will call refresh so our new result will be processed inside of the refresh()
            # method.
            return InputState.PROCESSED_AND_REDRAW
        else:
            # Not input for our screen, try other default inputs. This will result in the
            # same state as DISCARDED when no default option is used.
            return key


if __name__ == "__main__":
    # Initialize application (create scheduler and event loop).
    App.initialize()

    # Create our screen.
    screen = DividerScreen()

    # Schedule screen to the screen scheduler.
    # This can be called only after App.initialize().
    ScreenHandler.schedule_screen(screen)

    # Run the application. You must have some screen scheduled
    # otherwise it will end in an infinite loop.
    App.run()
    def schedule_screen_and_run_with_glib(self, screen):
        self.setup_glib()

        App.get_scheduler().schedule_screen(screen)
        App.run()
示例#13
0
 def schedule_screen_and_run(screen):
     App.initialize()
     App.get_scheduler().schedule_screen(screen)
     App.run()
    def test_quit_input(self, mock_stdin, mock_stdout):
        mock_stdin.return_value = "q"
        screen = UIScreen()

        App.get_scheduler().schedule_screen(screen)
        App.run()
    def test_failed_screen_setup(self):
        screen = FailedSetupScreenMock()

        App.initialize()
        App.get_scheduler().schedule_screen(screen)
        App.run()
示例#16
0
 def test_run_with_empty_screen_stack(self):
     App.initialize()
     with self.assertRaises(NothingScheduledError):
         App.run()
示例#17
0
 def test_run_shortcut(self, run_mock):
     App.initialize()
     App.get_configuration().should_run_with_empty_stack = True
     App.run()
     self.assertTrue(run_mock.called)