コード例 #1
0
    def refresh(self, args=None):
        """
        The refresh method that is called every time the spoke is displayed.
        It should update the UI elements according to the contents of
        self.data.

        :see: pyanaconda.ui.common.UIObject.refresh
        :see: simpleline.render.screen.UIScreen.refresh
        :param args: optional argument that may be used when the screen is
                     scheduled
        :type args: anything
        """
        super().refresh(args)
        self._container = ListColumnContainer(columns=1)

        # add ListColumnContainer to window (main window container)
        # this will automatically add numbering and will call callbacks when required
        self.window.add(self._container)

        self._container.add(CheckboxWidget(title="Simple checkbox",
                                           completed=self._checked),
                            callback=self._checkbox_called)
        self._container.add(EntryWidget(title="Unconditional text input",
                                        value=self._unconditional_input),
                            callback=self._get_unconditional_input)

        # show conditional input only if the checkbox is checked
        if self._checked:
            self._container.add(EntryWidget(
                title="Conditional password input",
                value="Password set" if self._conditional_input else ""),
                                callback=self._get_conditional_input)

        self._window.add_separator()
コード例 #2
0
    def test_entry_value_empty(self):
        title = "Title"
        w = EntryWidget(title=title)

        w.render(20)

        expected_result = [title]

        self.evaluate_result(w.get_lines(), expected_result=expected_result)
コード例 #3
0
    def test_entry_too_long(self):
        title = "Title too long"
        value = "Value also too long"
        w = EntryWidget(title=title, value=value)

        w.render(10)

        expected_result = [u"Title too", u"long", u"Value also", u"too long"]

        self.evaluate_result(w.get_lines(), expected_result)
コード例 #4
0
    def test_entry_widget(self):
        title = "Title"
        value = "Value"
        w = EntryWidget(title=title, value=value)

        w.render(30)

        expected_result = [title, value]

        self.evaluate_result(w.get_lines(), expected_result)
コード例 #5
0
    def refresh(self, args=None):
        super().refresh()

        main_columns = ListColumnContainer(columns=1, numbering=True)

        add_kvm_widget = EntryWidget(title="KVM Name", value=args["vm_name"])
        remove_kvm_widget = EntryWidget(title="KVM Hostname",
                                        value=args["vm_hostname"])

        main_columns.add(add_kvm_widget)
        main_columns.add(remove_kvm_widget)

        self.window.add(main_columns)
コード例 #6
0
    def refresh(self, args=None):
        """ Refresh window. """
        NormalTUISpoke.refresh(self, args)

        self._container = ListColumnContainer(1)

        dialog = Dialog(title=_("SERVER:/PATH"), conditions=[self._check_nfs_server])
        self._container.add(EntryWidget(dialog.title, self._nfs_server), self._set_nfs_server, dialog)

        dialog = Dialog(title=_("NFS mount options"))
        self._container.add(EntryWidget(dialog.title, self._nfs_opts), self._set_nfs_opts, dialog)

        self.window.add_with_separator(self._container)
コード例 #7
0
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        self._container = ListColumnContainer(1)

        mount_point_title = _("Mount point")
        reformat_title = _("Reformat")
        none_msg = _("none")

        fmt = get_format(self._mount_data.format)
        if fmt and fmt.mountable:
            dialog = Dialog(mount_point_title,
                            conditions=[self._check_assign_mount_point])
            value = self._mount_data.mount_point or none_msg
            self._container.add(EntryWidget(dialog.title, value),
                                self._assign_mount_point, dialog)
        elif fmt and fmt.type is None:
            # mount point cannot be set for no format
            # (fmt.name = "Uknown" in this case which would look weird)
            self._container.add(EntryWidget(mount_point_title, none_msg),
                                lambda x: self.redraw())
        else:
            # mount point cannot be set for format that is not mountable, just
            # show the format's name in square brackets instead
            self._container.add(EntryWidget(mount_point_title, fmt.name),
                                lambda x: self.redraw())

        dialog = Dialog(_("Format"), conditions=[self._check_format])
        value = self._mount_data.format or none_msg
        self._container.add(EntryWidget(dialog.title, value), self._set_format,
                            dialog)

        if ((self._mount_data.orig_format
             and self._mount_data.orig_format != self._mount_data.format)
                or self._mount_data.mount_point == "/"):
            # changing format implies reformat and so does "/" mount point
            self._container.add(
                CheckboxWidget(title=reformat_title,
                               completed=self._mount_data.reformat))
        else:
            self._container.add(
                CheckboxWidget(title=reformat_title,
                               completed=self._mount_data.reformat),
                self._switch_reformat)

        self.window.add_with_separator(self._container)
        self.window.add_with_separator(
            TextWidget(
                _("Choose from above to assign mount point and/or set format.")
            ))
コード例 #8
0
ファイル: user.py プロジェクト: sandrobonazzola/anaconda
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        # refresh the user list
        self._user_list = get_user_list(self._users_module,
                                        add_default=True,
                                        add_if_not_empty=self._user_cleared)

        self._is_admin = self.user.has_admin_priviledges()
        self._groups = ", ".join(self.user.groups)

        self._container = ListColumnContainer(1)

        w = CheckboxWidget(title=_("Create user"), completed=self._create_user)
        self._container.add(w, self._set_create_user)

        if self._create_user:
            dialog = Dialog(title=_("Full name"),
                            conditions=[self._check_fullname])
            self._container.add(EntryWidget(dialog.title, self.user.gecos),
                                self._set_fullname, dialog)

            dialog = Dialog(title=_("User name"),
                            conditions=[self._check_username])
            self._container.add(EntryWidget(dialog.title, self.user.name),
                                self._set_username, dialog)

            w = CheckboxWidget(title=_("Use password"),
                               completed=self._use_password)
            self._container.add(w, self._set_use_password)

            if self._use_password:
                password_dialog = PasswordDialog(
                    title=_("Password"), policy_name=PASSWORD_POLICY_USER)
                if self.user.password:
                    entry = EntryWidget(password_dialog.title, _(PASSWORD_SET))
                else:
                    entry = EntryWidget(password_dialog.title)

                self._container.add(entry, self._set_password, password_dialog)

            msg = _("Administrator")
            w = CheckboxWidget(title=msg, completed=self._is_admin)
            self._container.add(w, self._set_administrator)

            dialog = Dialog(title=_("Groups"), conditions=[self._check_groups])
            self._container.add(EntryWidget(dialog.title, self._groups),
                                self._set_groups, dialog)

        self.window.add_with_separator(self._container)
コード例 #9
0
    def refresh(self, args=None):
        """
        The refresh method that is called every time the spoke is displayed.
        It should update the UI elements according to the contents of
        self.data.

        :see: pyanaconda.ui.common.UIObject.refresh
        :see: simpleline.render.screen.UIScreen.refresh
        :param args: optional argument that may be used when the screen is
                     scheduled
        :type args: anything
        """
        # call parent method to setup basic container with screen title set
        super().refresh(args)

        self._reverse = self._hello_world_module.Reverse
        self._entered_text = "".join(self._hello_world_module.Lines)

        self._container = ListColumnContainer(columns=1)
        self.window.add(self._container)

        self._container.add(CheckboxWidget(title="Reverse",
                                           completed=self._reverse),
                            callback=self._change_reverse)
        self._container.add(EntryWidget(title="Hello world text",
                                        value=self._entered_text),
                            callback=self._change_lines)

        self._window.add_separator()
コード例 #10
0
ファイル: storage.py プロジェクト: yugart/anaconda
    def _add_mount_point_widget(self):
        """Add a widget for mount point assignment."""
        title = _("Mount point")
        fmt = DeviceFormatData.from_structure(
            self._device_tree.GetFormatTypeData(self._request.format_type)
        )

        if fmt.mountable:
            # mount point can be set
            value = self._request.mount_point or _("none")
            callback = self._assign_mount_point
        elif not fmt.type:
            # mount point cannot be set for no format
            # (fmt.name = "Unknown" in this case which would look weird)
            value = _("none")
            callback = None
        else:
            # mount point cannot be set for format that is not mountable, just
            # show the format's name in square brackets instead
            value = fmt.description
            callback = None

        dialog = Dialog(title, conditions=[self._check_assign_mount_point])
        widget = EntryWidget(dialog.title, value)
        self._container.add(widget, callback, dialog)
コード例 #11
0
ファイル: user.py プロジェクト: xuhuilong/anaconda
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)
        self._is_admin = "wheel" in self._user_data.groups
        self._groups = ", ".join(self._user_data.groups)

        self._container = ListColumnContainer(1)

        w = CheckboxWidget(title=_("Create user"), completed=self._create_user)
        self._container.add(w, self._set_create_user)

        if self._create_user:
            dialog = Dialog(title=_("Full name"),
                            conditions=[self._check_fullname])
            self._container.add(
                EntryWidget(dialog.title, self._user_data.gecos),
                self._set_fullname, dialog)

            dialog = Dialog(title=_("User name"),
                            conditions=[self._check_username])
            self._container.add(
                EntryWidget(dialog.title, self._user_data.name),
                self._set_username, dialog)

            w = CheckboxWidget(title=_("Use password"),
                               completed=self._use_password)
            self._container.add(w, self._set_use_password)

            if self._use_password:
                password_dialog = PasswordDialog(title=_("Password"),
                                                 policy=self._policy)
                if self._user_data.password:
                    entry = EntryWidget(password_dialog.title, _(PASSWORD_SET))
                else:
                    entry = EntryWidget(password_dialog.title)

                self._container.add(entry, self._set_password, password_dialog)

            msg = _("Administrator")
            w = CheckboxWidget(title=msg, completed=self._is_admin)
            self._container.add(w, self._set_administrator)

            dialog = Dialog(title=_("Groups"), conditions=[self._check_groups])
            self._container.add(EntryWidget(dialog.title, self._groups),
                                self._set_groups, dialog)

        self.window.add_with_separator(self._container)
コード例 #12
0
    def refresh(self, args=None):
        """ Refresh window. """
        NormalTUISpoke.refresh(self, args)

        self._container = ListColumnContainer(1)

        dialog = Dialog(_("Repo URL"))
        self._container.add(EntryWidget(dialog.title, self._url), self._set_repo_url, dialog)

        self.window.add_with_separator(self._container)
コード例 #13
0
ファイル: network.py プロジェクト: larskarlitski/anaconda
    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))
コード例 #14
0
    def _add_mount_point_widget(self):
        """Add a widget for mount point assignment."""
        title = _("Mount point")
        fmt = get_format(self._mount_data[MOUNT_POINT_FORMAT])

        if fmt and fmt.mountable:
            # mount point can be set
            value = self._mount_data[MOUNT_POINT_PATH] or _("none")
            callback = self._assign_mount_point
        elif fmt and fmt.type is None:
            # mount point cannot be set for no format
            # (fmt.name = "Unknown" in this case which would look weird)
            value = _("none")
            callback = None
        else:
            # mount point cannot be set for format that is not mountable, just
            # show the format's name in square brackets instead
            value = fmt.name
            callback = None

        dialog = Dialog(title, conditions=[self._check_assign_mount_point])
        widget = EntryWidget(dialog.title, value)
        self._container.add(widget, callback, dialog)
コード例 #15
0
 def _add_format_widget(self):
     """Add a widget for format."""
     dialog = Dialog(_("Format"), conditions=[self._check_format])
     widget = EntryWidget(dialog.title, self._mount_data[MOUNT_POINT_FORMAT]
                          or _("none"))
     self._container.add(widget, self._set_format, dialog)
コード例 #16
0
ファイル: storage.py プロジェクト: jstodola/anaconda
 def _add_format_widget(self):
     """Add a widget for format."""
     dialog = Dialog(_("Format"), conditions=[self._check_format])
     widget = EntryWidget(dialog.title, self._request.format_type
                          or _("none"))
     self._container.add(widget, self._set_format, dialog)
コード例 #17
0
 def _create_reserve_amount_text_widget(self):
     title = _("Reserve amount (%d - %d MB)" % (self._lower, self._upper))
     reserve_amount_entry = EntryWidget(title=title, value=self._addon_data.reserveMB)
     self._container.add(reserve_amount_entry, self._get_reserve_amount)