Esempio n. 1
0
    def _get_unconditional_input(self, data):  # pylint: disable=unused-argument
        """Callback when user wants to set unconditional input.

        :param data: can be passed when adding callback in container (not used here)
        :type data: anything
        """
        dialog = Dialog("Unconditional input", conditions=[self._check_user_input])

        self._unconditional_input = dialog.run()
Esempio n. 2
0
    def _change_lines(self, data):  # pylint: disable=unused-argument
        """Callback when user wants to input new lines.

        :param data: can be passed when adding callback in container (not used here)
        :type data: anything
        """
        dialog = Dialog("Lines")
        self._entered_text = dialog.run()
        lines = self._entered_text.splitlines(True)
        self._hello_world_module.SetLines(lines)
    def _get_unconditional_input(self, data):
        """Callback when user wants to set unconditional input.

        :param data: can be passed when adding callback in container (not used here)
        :type data: anything
        """

        dialog = Dialog("Unconditional input", conditions=[self._check_user_input])

        self._unconditional_input = dialog.run()
Esempio n. 4
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)
Esempio n. 5
0
    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)
Esempio n. 6
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.")
            ))
Esempio n. 7
0
    def refresh(self, args=None):
        """ Refresh screen. """
        self._load_new_devices()
        NormalTUISpoke.refresh(self, args)

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

        summary = self._summary_text()
        self.window.add_with_separator(TextWidget(summary))
        hostname = _("Host Name: %s\n") % self._network_module.proxy.Hostname
        self.window.add_with_separator(TextWidget(hostname))
        current_hostname = _(
            "Current host name: %s\n"
        ) % self._network_module.proxy.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 dev_name in self.supported_devices:
            text = (_("Configure device %s") % dev_name)
            self._container.add(TextWidget(text),
                                callback=self._configure_network_interface,
                                data=dev_name)

        self.window.add_with_separator(self._container)
Esempio n. 8
0
    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)
Esempio n. 9
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)
Esempio n. 10
0
    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)
Esempio n. 11
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)
Esempio n. 12
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))
Esempio n. 13
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)
Esempio n. 14
0
    def _get_reserve_amount(self, data):
        text = "Reserve amount (%d - %d MB)" % (self._lower, self._upper)
        dialog = Dialog(title=text, conditions=[self._check_reserve_valid])

        self._addon_data.reserveMB = dialog.run()
Esempio n. 15
0
 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)
Esempio n. 16
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)