Example #1
0
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)
        threadMgr.wait(THREAD_PAYLOAD)

        self._container = ListColumnContainer(1, columns_width=78, spacing=1)

        if args == self.SET_NETWORK_INSTALL_MODE:
            if self.payload.mirrors_available:
                self._container.add(TextWidget(_("Closest mirror")),
                                    self._set_network_close_mirror)

            self._container.add(TextWidget("http://"), self._set_network_url,
                                SpecifyRepoSpoke.HTTP)
            self._container.add(TextWidget("https://"), self._set_network_url,
                                SpecifyRepoSpoke.HTTPS)
            self._container.add(TextWidget("ftp://"), self._set_network_url,
                                SpecifyRepoSpoke.FTP)
            self._container.add(TextWidget("nfs"), self._set_network_nfs)
        else:
            self.window.add(
                TextWidget(_("Choose an installation source type.")))
            self._container.add(TextWidget(_("CD/DVD")),
                                self._set_cd_install_source)
            self._container.add(TextWidget(_("local ISO file")),
                                self._set_iso_install_source)
            self._container.add(TextWidget(_("Network")),
                                self._set_network_install_source)

            if self._hmc:
                self._container.add(TextWidget(_("SE/HMC")),
                                    self._set_hmc_install_source)

        self.window.add_with_separator(self._container)
Example #2
0
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        self._container = ListColumnContainer(1, columns_width=78, spacing=1)

        # check if the storage refresh thread is running
        if threadMgr.get(THREAD_STORAGE_WATCHER):
            # storage refresh is running - just report it
            # so that the user can refresh until it is done
            # TODO: refresh once the thread is done ?
            message = _(PAYLOAD_STATUS_PROBING_STORAGE)
            self.window.add_with_separator(TextWidget(message))

        # check if there are any mountable devices
        if self._mountable_devices:
            for d in self._mountable_devices:
                self._container.add(TextWidget(d[1]),
                                    callback=self._select_mountable_device,
                                    data=d[0])

            self.window.add_with_separator(self._container)

        else:
            message = _("No mountable devices found")
            self.window.add_with_separator(TextWidget(message))
Example #3
0
    def refresh(self, args=None):
        super().refresh(args)

        msg = _("The rescue environment will now attempt "
                "to find your Linux installation and mount it under "
                "the directory : %s.  You can then make any changes "
                "required to your system.  Choose '1' to proceed with "
                "this step.\nYou can choose to mount your file "
                "systems read-only instead of read-write by choosing "
                "'2'.\nIf for some reason this process does not work "
                "choose '3' to skip directly to a shell.\n\n") % (
                    util.getSysroot())
        self.window.add_with_separator(TextWidget(msg))

        self._container = ListColumnContainer(1)

        self._container.add(TextWidget(_("Continue")),
                            self._read_write_mount_callback)
        self._container.add(TextWidget(_("Read-only mount")),
                            self._read_only_mount_callback)
        self._container.add(TextWidget(_("Skip to shell")),
                            self._skip_to_shell_callback)
        self._container.add(TextWidget(_("Quit (Reboot)")),
                            self._quit_callback)

        self.window.add_with_separator(self._container)
Example #4
0
        def _prep_text(i, entry):
            number = TextWidget("%2d)" % i)
            title = TextWidget(_(entry.title))
            value = getdeepattr(self.args, entry.attribute)
            value = TextWidget(value)

            return ColumnWidget([(3, [number]), (None, [title, value])], 1)
Example #5
0
    def refresh(self, args=None):
        """ Refresh screen. """
        NormalTUISpoke.refresh(self, args)
        self._container = None

        if not self._source_is_set:
            message = TextWidget(
                _("Installation source needs to be set up first."))
            self.window.add_with_separator(message)
            return

        threadMgr.wait(THREAD_CHECK_SOFTWARE)
        self._container = ListColumnContainer(columns=2,
                                              columns_width=38,
                                              spacing=2)

        for environment in self._selection_cache.available_environments:
            data = self._dnf_manager.get_environment_data(environment)
            selected = self._selection_cache.is_environment_selected(
                environment)

            widget = CheckboxWidget(title=data.name, completed=selected)

            self._container.add(widget,
                                callback=self._select_environment,
                                data=data.id)

        self.window.add_with_separator(TextWidget(_("Base environment")))
        self.window.add_with_separator(self._container)
Example #6
0
    def refresh(self, args=None):
        super().refresh()

        # Text widget
        # Show text to user. This is basic widget which will handle
        # wrapping of words for you.
        text_widget = TextWidget("Text widget")
        self.window.add_with_separator(text_widget)

        # Center widget
        # Wrap extisting widget and center it to the middle of the screen.
        text = TextWidget("Center widget")
        center_widget = CenterWidget(text)
        self.window.add_with_separator(
            center_widget, blank_lines=3)  # Add two more blank lines

        # Checkbox widget
        # Checkbox which can hold 2 states.
        checkbox_widget = CheckboxWidget(key="o",
                                         title="Checkbox title",
                                         text="Checkbox text",
                                         completed=True)
        self.window.add_with_separator(checkbox_widget)

        # Checkbox widget unchecked
        checkbox_widget_unchecked = CheckboxWidget(key="o",
                                                   title="Checkbox title",
                                                   text="Unchecked",
                                                   completed=False)
        self.window.add_with_separator(checkbox_widget_unchecked)
    def _draw_title_and_separator(self, width):
        title_widget = TextWidget(self._title)
        sep = SeparatorWidget()

        title_widget.render(width)
        sep.render(width)

        self.draw(title_widget)
        self.draw(sep)
Example #8
0
        def _prep_password(i, entry):
            number = TextWidget("%2d)" % i)
            title = TextWidget(_(entry.title))
            value = ""
            if len(getdeepattr(self.args, entry.attribute)) > 0:
                value = _("Password set.")
            value = TextWidget(value)

            return ColumnWidget([(3, [number]), (None, [title, value])], 1)
Example #9
0
    def test_window_container_wrapping(self):
        c = WindowContainer(title="Test")

        c.add(TextWidget("Body long line"))
        c.add(TextWidget("Body"))
        c.render(5)

        expected_result = [u"Test", u"", u"Body", u"long", u"line", u"Body"]

        res_lines = c.get_lines()
        self.evaluate_result(res_lines, expected_result)
Example #10
0
    def test_window_container_with_multiple_items(self):
        c = WindowContainer(title="Test")

        c.add(TextWidget("Body"))
        c.add(TextWidget("Body second line"))
        c.render(30)

        expected_result = [u"Test", u"", u"Body", u"Body second line"]

        res_lines = c.get_lines()
        self.evaluate_result(res_lines, expected_result)
Example #11
0
    def test_list_container_too_small(self):
        # to be able to render this container we need at least 11 width
        # 8 will take only spacing and then 1 for every column
        c = ListRowContainer(3, spacing=4, numbering=False)

        c.add(TextWidget("This can't be rendered."))
        c.add(
            TextWidget("Because spacing takes more space than maximal width."))
        c.add(TextWidget("Exception will raise."))

        with self.assertRaisesRegex(ValueError, "Columns width is too small."):
            c.render(10)
Example #12
0
    def refresh(self, args=None):
        super().refresh(args)

        umount_msg = _("Run %s to unmount the system when you are finished."
                       ) % ANACONDA_CLEANUP
        exit_reboot_msg = _(
            "When finished, please exit from the shell and your "
            "system will reboot.\n")
        text = None

        if self._rescue.mount:
            status = self._rescue.status
            if status == RescueModeStatus.MOUNTED:
                if self._rescue.reboot:
                    finish_msg = exit_reboot_msg
                else:
                    finish_msg = umount_msg
                text = TextWidget(
                    _("Your system has been mounted under %(mountpoint)s.\n\n"
                      "If you would like to make the root of your system the "
                      "root of the active system, run the command:\n\n"
                      "\tchroot %(mountpoint)s\n\n") %
                    {"mountpoint": conf.target.system_root} + finish_msg)
            elif status == RescueModeStatus.MOUNT_FAILED:
                if self._rescue.reboot:
                    finish_msg = exit_reboot_msg
                else:
                    finish_msg = umount_msg

                msg = _(
                    "An error occurred trying to mount some or all of your system: "
                    "{message}\n\nSome of it may be mounted under {path}."
                ).format(message=str(self._rescue.error),
                         path=conf.target.system_root)

                text = TextWidget(msg + " " + finish_msg)
            elif status == RescueModeStatus.ROOT_NOT_FOUND:
                if self._rescue.reboot:
                    finish_msg = _("Rebooting.")
                else:
                    finish_msg = ""
                text = TextWidget(
                    _("You don't have any Linux partitions. %s\n") %
                    finish_msg)
        else:
            if self._rescue.reboot:
                finish_msg = exit_reboot_msg
            else:
                finish_msg = ""
            text = TextWidget(_("Not mounting the system.\n") + finish_msg)

        self.window.add(text)
Example #13
0
    def refresh(self, args=None):
        super().refresh()

        menu_column = ListColumnContainer(columns=1)

        # Menu Items
        config_kvm_widget = TextWidget("Add KVM")
        network_kvm_widget = TextWidget("View/Edit KVM")

        menu_column.add(config_kvm_widget)
        menu_column.add(network_kvm_widget)

        self.window.add(menu_column)
Example #14
0
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        if self._isos:
            self._container = ListColumnContainer(1, columns_width=78, spacing=1)

            for iso in self._isos:
                self._container.add(TextWidget(iso), callback=self._select_iso_callback, data=iso)

            self.window.add_with_separator(self._container)
        else:
            message = _("No *.iso files found in device root folder")
            self.window.add_with_separator(TextWidget(message))
Example #15
0
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        self.window.add_with_separator(TextWidget(self._message))

        self._container = ListColumnContainer(1, spacing=1)

        # choices are
        # USE VNC
        self._container.add(TextWidget(_(USEVNC)), self._use_vnc_callback)
        # USE TEXT
        self._container.add(TextWidget(_(USETEXT)), self._use_text_callback)

        self.window.add_with_separator(self._container)
Example #16
0
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        umount_msg = _("Run %s to unmount the system when you are finished."
                       ) % ANACONDA_CLEANUP
        exit_reboot_msg = _(
            "When finished, please exit from the shell and your "
            "system will reboot.\n")
        text = None

        if self._rescue.mount:
            status = self._rescue.status
            if status == RescueModeStatus.MOUNTED:
                if self._rescue.reboot:
                    finish_msg = exit_reboot_msg
                else:
                    finish_msg = umount_msg
                text = TextWidget(
                    _("Your system has been mounted under %(mountpoint)s.\n\n"
                      "If you would like to make the root of your system the "
                      "root of the active system, run the command:\n\n"
                      "\tchroot %(mountpoint)s\n") %
                    {"mountpoint": util.getSysroot()} + finish_msg)
            elif status == RescueModeStatus.MOUNT_FAILED:
                if self._rescue.reboot:
                    finish_msg = exit_reboot_msg
                else:
                    finish_msg = umount_msg
                text = TextWidget(
                    _("An error occurred trying to mount some or all of "
                      "your system.  Some of it may be mounted under %s\n\n") %
                    util.getSysroot() + finish_msg)
            elif status == RescueModeStatus.ROOT_NOT_FOUND:
                if self._rescue.reboot:
                    finish_msg = _("Rebooting.")
                else:
                    finish_msg = ""
                text = TextWidget(
                    _("You don't have any Linux partitions. %s\n") %
                    finish_msg)
        else:
            if self._rescue.reboot:
                finish_msg = exit_reboot_msg
            else:
                finish_msg = ""
            text = TextWidget(_("Not mounting the system.\n") + finish_msg)

        self.window.add(text)
        return InputState.PROCESSED
Example #17
0
    def test_list_container_too_small_turn_off_numbering(self):
        # to be able to render this container we need 11 width + three times numbers (3 characters) = 20
        # 8 will take only spacing and then 1 for every column
        c = ListRowContainer(3, spacing=4, numbering=True)

        c.add(TextWidget("This can't be rendered."))
        c.add(
            TextWidget("Because spacing takes more space than maximal width."))
        c.add(
            TextWidget(
                "Exception will raise with info to turn off numbering."))

        with self.assertRaisesRegex(
                ValueError, "Increase column width or disable numbering."):
            c.render(19)
Example #18
0
    def refresh(self, args=None):
        super().refresh(args)

        summary = self._summary_text()
        self.window.add_with_separator(TextWidget(summary))

        self._container = ListColumnContainer(1, columns_width=78, spacing=1)

        self._container.add(TextWidget(_("Add NTP server")), self._add_ntp_server)

        # only add the remove option when we can remove something
        if self._time_spoke.ntp_servers:
            self._container.add(TextWidget(_("Remove NTP server")), self._remove_ntp_server)

        self.window.add_with_separator(self._container)
Example #19
0
    def refresh(self, args=None):
        """ Refresh screen. """
        NormalTUISpoke.refresh(self, args)

        threadMgr.wait(THREAD_PAYLOAD)
        self._container = None

        if not self.payload.baseRepo:
            message = TextWidget(
                _("Installation source needs to be set up first."))
            self.window.add_with_separator(message)
            return

        threadMgr.wait(THREAD_CHECK_SOFTWARE)
        self._container = ListColumnContainer(2, columns_width=38, spacing=2)

        # Display the environments
        if args is None:
            environments = self.payload.environments
            msg = _("Base environment")

            for env in environments:
                name = self.payload.environmentDescription(env)[0]
                selected = (env == self._selected_environment)
                widget = CheckboxWidget(title="%s" % name, completed=selected)
                self._container.add(widget,
                                    callback=self._set_environment_callback,
                                    data=env)

        # Display the add-ons
        else:
            length = len(args)

            if length > 0:
                msg = _("Add-ons for selected environment")
            else:
                msg = _("No add-ons to select.")

            for addon_id in args:
                name = self.payload.groupDescription(addon_id)[0]
                selected = addon_id in self._addons_selection
                widget = CheckboxWidget(title="%s" % name, completed=selected)
                self._container.add(widget,
                                    callback=self._set_addons_callback,
                                    data=addon_id)

        self.window.add_with_separator(TextWidget(msg))
        self.window.add_with_separator(self._container)
Example #20
0
    def refresh(self, args=None):
        """args is None if we want a list of zones or "zone" to show all timezones in that zone."""
        super().refresh(args)

        self._container = ListColumnContainer(3, columns_width=24)

        if args and args in self._timezones:
            self.window.add(TextWidget(_("Available timezones in region %s") % args))
            for tz in self._timezones[args]:
                self._container.add(TextWidget(tz), self._select_timezone_callback, CallbackTimezoneArgs(args, tz))
        else:
            self.window.add(TextWidget(_("Available regions")))
            for region in self._regions:
                self._container.add(TextWidget(region), self._select_region_callback, region)

        self.window.add_with_separator(self._container)
Example #21
0
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        # Join the initialization thread to block on it
        # This print is foul.  Need a better message display
        print(_(PAYLOAD_STATUS_PROBING_STORAGE))
        threadMgr.wait(THREAD_STORAGE_WATCHER)

        # synchronize our local data store with the global ksdata
        # Commment out because there is no way to select a disk right
        # now without putting it in ksdata.  Seems wrong?
        #self.selected_disks = self.data.ignoredisk.onlyuse[:]
        self.autopart = self.data.autopart.autopart

        self._container = ListColumnContainer(1, spacing=1)

        message = self._update_summary()

        # loop through the disks and present them.
        for disk in self.disks:
            disk_info = self._format_disk_info(disk)
            c = CheckboxWidget(title=disk_info,
                               completed=(disk.name in self.selected_disks))
            self._container.add(c, self._update_disk_list_callback, disk)

        # if we have more than one disk, present an option to just
        # select all disks
        if len(self.disks) > 1:
            c = CheckboxWidget(title=_("Select all"),
                               completed=self.select_all)
            self._container.add(c, self._select_all_disks_callback)

        self.window.add_with_separator(self._container)
        self.window.add_with_separator(TextWidget(message))
Example #22
0
    def test_list_callback_without_data(self, out_mock, in_mock):
        c = ListRowContainer(1)

        c.add(TextWidget("Test"), self._callback)

        self.assertTrue(c.process_user_input("1"))
        self.assertIsNone(self._callback_called)
Example #23
0
    def refresh(self, args=None):
        """Refresh the screen."""
        NormalTUISpoke.refresh(self, args)

        self._container = ListColumnContainer(columns=2,
                                              columns_width=38,
                                              spacing=2)

        for group in self._selection_cache.available_groups:
            data = self._dnf_manager.get_group_data(group)
            selected = self._selection_cache.is_group_selected(group)

            widget = CheckboxWidget(title=data.name, completed=selected)

            self._container.add(widget,
                                callback=self._select_group,
                                data=data.id)

        if self._selection_cache.available_groups:
            msg = _("Additional software for selected environment")
        else:
            msg = _("No additional software to select.")

        self.window.add_with_separator(TextWidget(msg))
        self.window.add_with_separator(self._container)
Example #24
0
    def refresh(self, args=None):
        """Refresh the window."""
        super().refresh(args)
        self._container = ListColumnContainer(2)

        for request in self._requests:
            widget = TextWidget(self._get_request_description(request))
            self._container.add(widget, self._configure_request, request)

        message = _(
            "Choose device from above to assign mount point and set format.\n"
            "Formats marked with * are new formats meaning ALL DATA on the "
            "original format WILL BE LOST!")

        self.window.add_with_separator(self._container)
        self.window.add_with_separator(TextWidget(message))
Example #25
0
    def refresh(self, args=None):
        """Prepare the content of the screen."""
        super().refresh(args)
        threadMgr.wait(THREAD_STORAGE_WATCHER)

        # Get the available partitioning.
        object_path = self._storage_module.CreatedPartitioning[-1]
        self._partitioning = STORAGE.get_proxy(object_path)

        # Create a new container.
        self._container = ListColumnContainer(1, spacing=1)

        # loop through the disks and present them.
        for disk_name in self._available_disks:
            disk_info = self._format_disk_info(disk_name)
            c = CheckboxWidget(title=disk_info,
                               completed=(disk_name in self._selected_disks))
            self._container.add(c, self._update_disk_list_callback, disk_name)

        # if we have more than one disk, present an option to just
        # select all disks
        if len(self._available_disks) > 1:
            c = CheckboxWidget(title=_("Select all"),
                               completed=self._select_all)
            self._container.add(c, self._select_all_disks_callback)

        self.window.add_with_separator(self._container)
        self.window.add_with_separator(TextWidget(self._update_summary()))
Example #26
0
    def refresh(self, args=None):
        super().refresh(args)

        self._list_widget = ListRowContainer(2)
        for i in range(self._widgets_count):
            self._list_widget.add(TextWidget("Test %s" % i), self._callback, i)

        self.window.add(self._list_widget)
Example #27
0
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        summary = self._summary_text()
        self.window.add_with_separator(TextWidget(summary))

        if self._timezone_module.proxy.Timezone:
            timezone_option = _("Change timezone")
        else:
            timezone_option = _("Set timezone")

        self._container = ListColumnContainer(1, columns_width=78, spacing=1)

        self._container.add(TextWidget(timezone_option), callback=self._timezone_callback)
        self._container.add(TextWidget(_("Configure NTP servers")), callback=self._configure_ntp_server_callback)

        self.window.add_with_separator(self._container)
Example #28
0
    def refresh(self, args=None):
        """ Refresh screen. """
        NormalTUISpoke.refresh(self, args)

        self._container = ListColumnContainer(1, columns_width=78, spacing=1)

        if not self.nm_client:
            self.window.add_with_separator(TextWidget(_("Network configuration is not available.")))
            return

        summary = self._summary_text()
        self.window.add_with_separator(TextWidget(summary))

        hostname = _("Host Name: %s\n") % self._network_module.Hostname
        self.window.add_with_separator(TextWidget(hostname))
        current_hostname = _("Current host name: %s\n") % self._network_module.GetCurrentHostname()
        self.window.add_with_separator(TextWidget(current_hostname))

        # if we have any errors, display them
        while len(self.errors) > 0:
            self.window.add_with_separator(TextWidget(self.errors.pop()))

        dialog = Dialog(_("Host Name"))
        self._container.add(TextWidget(_("Set host name")), callback=self._set_hostname_callback, data=dialog)

        for device_configuration in self.editable_configurations:
            iface = device_configuration.device_name
            text = (_("Configure device %s") % iface)
            self._container.add(TextWidget(text), callback=self._ensure_connection_and_configure,
                                data=iface)

        self.window.add_with_separator(self._container)
Example #29
0
    def refresh(self, args=None):
        """ Refresh window. """
        super().refresh(args)

        self._container = ListColumnContainer(1)

        dialog = Dialog(title=(_('IPv4 address or %s for DHCP') % '"dhcp"'),
                        conditions=[self._check_ipv4_or_dhcp])
        self._container.add(EntryWidget(dialog.title, self.network_data.ip),
                            self._set_ipv4_or_dhcp, dialog)

        dialog = Dialog(title=_("IPv4 netmask"),
                        conditions=[self._check_netmask])
        self._container.add(
            EntryWidget(dialog.title, self.network_data.netmask),
            self._set_netmask, dialog)

        dialog = Dialog(title=_("IPv4 gateway"), conditions=[self._check_ipv4])
        self._container.add(
            EntryWidget(dialog.title, self.network_data.gateway),
            self._set_ipv4_gateway, dialog)

        msg = (_(
            'IPv6 address[/prefix] or %(auto)s for automatic, %(dhcp)s for DHCP, '
            '%(ignore)s to turn off') % {
                "auto": '"auto"',
                "dhcp": '"dhcp"',
                "ignore": '"ignore"'
            })
        dialog = Dialog(title=msg, conditions=[self._check_ipv6_config])
        self._container.add(EntryWidget(dialog.title, self.network_data.ipv6),
                            self._set_ipv6, dialog)

        dialog = Dialog(title=_("IPv6 default gateway"),
                        conditions=[self._check_ipv6])
        self._container.add(
            EntryWidget(dialog.title, self.network_data.ipv6gateway),
            self._set_ipv6_gateway, dialog)

        dialog = Dialog(title=_("Nameservers (comma separated)"),
                        conditions=[self._check_nameservers])
        self._container.add(
            EntryWidget(dialog.title, self.network_data.nameserver),
            self._set_nameservers, dialog)

        msg = _("Connect automatically after reboot")
        w = CheckboxWidget(title=msg, completed=self.network_data.onboot)
        self._container.add(w, self._set_onboot_handler)

        msg = _("Apply configuration in installer")
        w = CheckboxWidget(title=msg, completed=self.apply_configuration)
        self._container.add(w, self._set_apply_handler)

        self.window.add_with_separator(self._container)

        message = _("Configuring device %s.") % self.network_data.device
        self.window.add_with_separator(TextWidget(message))
 def refresh(self, args=None):
     """Print text to user with number of continue clicked."""
     super().refresh(args)
     # Print counter to the screen.
     widget = TextWidget("You pressed {} times on continue".format(self.continue_count))
     # Center this counter to middle of the screen.
     center_widget = CenterWidget(widget)
     # Add the centered widget to the window container.
     self.window.add(center_widget)