コード例 #1
0
ファイル: storage.py プロジェクト: nullr0ute/anaconda
    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

        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="%i) %s" % (self.disks.index(disk) + 1, disk_info),
                               completed=(disk.name in self.selected_disks))
            self._window += [c, ""]

        # if we have more than one disk, present an option to just
        # select all disks
        if len(self.disks) > 1:
            c = CheckboxWidget(title="%i) %s" % (len(self.disks) + 1, _("Select all")),
                                completed=(self.selection == len(self.disks)))

            self._window += [c, ""]

        self._window += [TextWidget(message), ""]

        return True
コード例 #2
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(_("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

        message = self._update_summary()

        # loop through the disks and present them.
        for disk in self.disks:
            size = size_str(disk.size)
            c = CheckboxWidget(
                title="%i) %s: %s (%s)" %
                (self.disks.index(disk) + 1, disk.model, size, disk.name),
                completed=(disk.name in self.selected_disks))
            self._window += [c, ""]

        self._window += [TextWidget(message), ""]

        return True
コード例 #3
0
ファイル: rescue.py プロジェクト: mariannecx/anaconda
    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")
        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": iutil.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") %
                    iutil.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.append(text)
        return True
コード例 #4
0
    def refresh(self, args=None):
        StandaloneTUISpoke.refresh(self, args)

        self._window += [
            TextWidget(self._message % {'features': self._unsupported}), ""
        ]

        return True
コード例 #5
0
ファイル: software.py プロジェクト: megaumi/anaconda
    def refresh(self, args=None):
        """ Refresh screen. """
        NormalTUISpoke.refresh(self, args)

        threadMgr.wait(THREAD_PAYLOAD)

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

            # add some more space below
            self._window.append(TextWidget(""))
            return True

        threadMgr.wait(THREAD_CHECK_SOFTWARE)

        # put a title above the list and some space below it
        self._window.append(TextWidget(_("Base environment")))
        self._window.append(TextWidget(""))

        environments = self.payload.environments

        displayed = []
        for env in environments:
            name = self.payload.environmentDescription(env)[0]

            displayed.append(
                CheckboxWidget(
                    title="%s" % name,
                    completed=(environments.index(env) == self._selection)))

        def _prep(i, w):
            """ Do some format magic for display. """
            num = TextWidget("%2d)" % (i + 1))
            return ColumnWidget([(4, [num]), (None, [w])], 1)

        # split list of DE's into two columns
        mid = len(environments) / 2
        left = [_prep(i, w) for i, w in enumerate(displayed) if i <= mid]
        right = [_prep(i, w) for i, w in enumerate(displayed) if i > mid]

        cw = ColumnWidget([(38, left), (38, right)], 2)
        self._window.append(cw)

        return True
コード例 #6
0
    def refresh(self, args=None):
        EditTUIDialog.refresh(self, args)

        self._window += [
            TextWidget(
                _("Please select new root password. You will have to type it twice."
                  )), ""
        ]

        return True
コード例 #7
0
ファイル: storage.py プロジェクト: bcl/anaconda
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        schemelist = self.partschemes.keys()
        for i, sch in enumerate(schemelist):
            box = CheckboxWidget(title="%i) %s" %(i + 1, _(sch)), completed=(i == self._selection))
            self._window += [box, ""]

        message = _("Select a partition scheme configuration.")
        self._window += [TextWidget(message), ""]
        return True
コード例 #8
0
ファイル: source.py プロジェクト: LiuCan01/anaconda
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        if self._isos:
            isos = [TextWidget(iso) for iso in self._isos]

            def _prep(i, w):
                """ Mangle our text to make it look pretty on screen. """
                number = TextWidget("%2d)" % (i + 1))
                return ColumnWidget([(4, [number]), (None, [w])], 1)

            # gnarl and mangle all of our widgets so things look pretty on screen
            choices = [_prep(i, w) for i, w in enumerate(isos)]

            displayed = ColumnWidget([(78, choices)], 1)
            self._window.append(displayed)
        else:
            message = _("No *.iso files found in device root folder")
            self._window += [TextWidget(message), ""]

        return True
コード例 #9
0
ファイル: rescue.py プロジェクト: nullr0ute/anaconda
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        self._window += [
            TextWidget(
                _("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") %
                (iutil.getSysroot())), ""
        ]

        for idx, choice in enumerate(self._choices):
            number = TextWidget("%2d)" % (idx + 1))
            c = ColumnWidget([(3, [number]), (None, [TextWidget(choice)])], 1)
            self._window += [c, ""]

        return True
コード例 #10
0
ファイル: rescue.py プロジェクト: nullr0ute/anaconda
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        message = _(
            "The following installations were discovered on your system.\n")
        self._window += [TextWidget(message), ""]

        for i, root in enumerate(self._roots):
            box = CheckboxWidget(title="%i) %s on %s" %
                                 (i + 1, _(root.name), root.device.path),
                                 completed=(self._selection == i))
            self._window += [box, ""]

        return True
コード例 #11
0
    def refresh(self, args=None):
        """ Refresh screen. """
        self._load_new_devices()
        EditTUISpoke.refresh(self, args)

        # on refresh check if we haven't got hostname from NM on activated
        # connection (dhcp or DNS)
        if self.hostname_dialog.value == network.DEFAULT_HOSTNAME:
            hostname = network.getHostname()
            network.update_hostname_data(self.data, hostname)
            self.hostname_dialog.value = self.data.network.hostname

        summary = self._summary_text()
        self._window += [TextWidget(summary), ""]
        hostname = _("Host Name: %s\n") % self.data.network.hostname
        self._window += [TextWidget(hostname), ""]

        # if we have any errors, display them
        while len(self.errors) > 0:
            self._window += [TextWidget(self.errors.pop()), ""]

        def _prep(i, w):
            """ Mangle our text to make it look pretty on screen. """
            number = TextWidget("%2d)" % (i + 1))
            return ColumnWidget([(4, [number]), (None, [w])], 1)

        _opts = [_("Set host name")]
        for devname in self.supported_devices:
            _opts.append(_("Configure device %s") % devname)
        text = [TextWidget(o) for o in _opts]

        # make everything presentable on screen
        choices = [_prep(i, w) for i, w in enumerate(text)]
        displayed = ColumnWidget([(78, choices)], 1)
        self._window.append(displayed)

        return True
コード例 #12
0
    def refresh(self, args=None):
        """
        args is None if we want a list of languages; or, it is a list of all
        locales for a language.
        """
        NormalTUISpoke.refresh(self, args)

        if args:
            self._window += [TextWidget(_("Available locales"))]
            displayed = [
                TextWidget(localization.get_english_name(z)) for z in args
            ]
        else:
            self._window += [TextWidget(_("Available languages"))]
            displayed = [TextWidget(z) for z in self._langs]

        def _prep(i, w):
            """ make everything look nice """
            number = TextWidget("%2d)" % (i + 1))
            return ColumnWidget([(4, [number]), (None, [w])], 1)

        # split zones to three columns
        middle = len(displayed) / 3
        left = [_prep(i, w) for i, w in enumerate(displayed) if i <= middle]
        center = [
            _prep(i, w) for i, w in enumerate(displayed)
            if i > middle and i <= 2 * middle
        ]
        right = [
            _prep(i, w) for i, w in enumerate(displayed) if i > 2 * middle
        ]

        c = ColumnWidget([(24, left), (24, center), (24, right)], 3)
        self._window.append(c)

        return True
コード例 #13
0
ファイル: time_spoke.py プロジェクト: mudler/anaconda
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        summary = self._summary_text()
        self._window += [TextWidget(summary), ""]

        _options = [_("Add NTP server")]
        # only add the remove option when we can remove something
        if self._time_spoke.ntp_servers:
            _options.append(_("Remove NTP server"))
        text = [TextWidget(m) for m in _options]

        def _prep(i, w):
            """ Mangle our text to make it look pretty on screen. """
            number = TextWidget("%2d)" % (i + 1))
            return ColumnWidget([(4, [number]), (None, [w])], 1)

        # gnarl and mangle all of our widgets so things look pretty on screen
        choices = [_prep(i, w) for i, w in enumerate(text)]

        displayed = ColumnWidget([(78, choices)], 1)
        self._window.append(displayed)

        return True
コード例 #14
0
ファイル: storage.py プロジェクト: bcl/anaconda
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)
        # synchronize our local data store with the global ksdata
        self.clearPartType = self.data.clearpart.type
        # I dislike "is None", but bool(0) returns false :(
        if self.clearPartType is None:
            # Default to clearing everything.
            self.clearPartType = CLEARPART_TYPE_ALL

        for i, parttype in enumerate(self.parttypelist):
            c = CheckboxWidget(title="%i) %s" % (i + 1, _(parttype)),
                               completed=(PARTTYPES[parttype] == self.clearPartType))
            self._window += [c, ""]

        message = _("Installation requires partitioning of your hard drive. Select what space to use for the install target.")

        self._window += [TextWidget(message), ""]

        return True
コード例 #15
0
    def _thread_input(self, queue_instance, prompt, hidden):
        """This method is responsible for interruptible user input.

        It is expected to be used in a thread started on demand by the App class
        and returns the input via the communication Queue.

        :param queue_instance: communication queue_instance to be used
        :type queue_instance: queue.Queue instance

        :param prompt: prompt to be displayed
        :type prompt: Prompt instance

        :param hidden: whether typed characters should be echoed or not
        :type hidden: bool
        """

        if hidden:
            data = self.simpleline_getpass(prompt)
        else:
            widget = TextWidget(str(prompt))
            widget.render(self.width)
            lines = widget.get_lines()
            sys.stdout.write("\n".join(lines) + " ")
            sys.stdout.flush()
            # XXX: only one raw_input can run at a time, don't schedule another
            # one as it would cause weird behaviour and block other packages'
            # raw_inputs
            if not RAW_INPUT_LOCK.acquire(False):
                # raw_input is already running
                return
            else:
                # lock acquired, we can run raw_input
                try:
                    data = input()
                except EOFError:
                    data = ""
                finally:
                    RAW_INPUT_LOCK.release()

        queue_instance.put((hubQ.HUB_CODE_INPUT, [data]))
コード例 #16
0
 def refresh(self, args=None):
     """ Refresh window. """
     EditTUISpoke.refresh(self, args)
     message = _("Configuring device %s." % self.args.device)
     self._window += [TextWidget(message), ""]
     return True
コード例 #17
0
 def _prep(i, w):
     """ Mangle our text to make it look pretty on screen. """
     number = TextWidget("%2d)" % (i + 1))
     return ColumnWidget([(4, [number]), (None, [w])], 1)
コード例 #18
0
 def _prep(i, w):
     number = TextWidget("%2d)" % (i + 1))
     return ColumnWidget([(4, [number]), (None, [w])], 1)
コード例 #19
0
    def refresh(self, args=None):
        """ Refresh screen. """
        NormalTUISpoke.refresh(self, args)

        threadMgr.wait(THREAD_PAYLOAD)

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

            # add some more space below
            self._window.append(TextWidget(""))
            return True

        threadMgr.wait(THREAD_CHECK_SOFTWARE)
        displayed = []

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

            for env in environments:
                name = self.payload.environmentDescription(env)[0]
                selected = environments.index(env) == self._selection
                displayed.append(
                    CheckboxWidget(title="%s" % name, completed=selected))

        # 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
                displayed.append(
                    CheckboxWidget(title="%s" % name, completed=selected))

        def _prep(i, w):
            """ Do some format magic for display. """
            num = TextWidget("%2d)" % (i + 1))
            return ColumnWidget([(4, [num]), (None, [w])], 1)

        # split list of DE's into two columns
        mid = length / 2
        left = [_prep(i, w) for i, w in enumerate(displayed) if i <= mid]
        right = [_prep(i, w) for i, w in enumerate(displayed) if i > mid]

        cw = ColumnWidget([(38, left), (38, right)], 2)

        self._window.append(TextWidget(msg))
        self._window.append(TextWidget(""))
        self._window.append(cw)
        self._window.append(TextWidget(""))
        return True
コード例 #20
0
ファイル: askvnc.py プロジェクト: nullr0ute/anaconda
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)
        self._window += [TextWidget(self._message), ""]

        return True
コード例 #21
0
ファイル: rescue.py プロジェクト: nullr0ute/anaconda
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        if self._root:
            try:
                mount_existing_system(self.storage.fsset,
                                      self._root.device,
                                      read_only=self.readOnly)
                if flags.automatedInstall:
                    log.info("System has been mounted under: %s",
                             iutil.getSysroot())
                else:
                    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": iutil.getSysroot()})
                    self._window.append(text)
                rootmounted = True

                # now turn on swap
                if not flags.imageInstall or not self.readOnly:
                    try:
                        self.storage.turn_on_swap()
                    except StorageError:
                        log.error("Error enabling swap.")

                # turn on selinux also
                if flags.selinux:
                    # we have to catch the possible exception, because we
                    # support read-only mounting
                    try:
                        fd = open("%s/.autorelabel" % iutil.getSysroot(), "w+")
                        fd.close()
                    except IOError:
                        log.warning("Cannot touch %s/.autorelabel",
                                    iutil.getSysroot())

                # set a libpath to use mounted fs
                libdirs = os.environ.get("LD_LIBRARY_PATH", "").split(":")
                mounted = list(
                    map(lambda dir: "/mnt/sysimage%s" % dir, libdirs))
                iutil.setenv("LD_LIBRARY_PATH", ":".join(libdirs + mounted))

                # do we have bash?
                try:
                    if os.access("/usr/bin/bash", os.R_OK):
                        os.symlink("/usr/bin/bash", "/bin/bash")
                except OSError:
                    pass
            except (ValueError, LookupError, SyntaxError, NameError):
                pass
            except (OSError, StorageError) as e:
                if flags.automatedInstall:
                    msg = _(
                        "Run %s to unmount the system when you are finished.\n"
                    ) % ANACONDA_CLEANUP

                text = TextWidget(
                    _("An error occurred trying to mount some or all of "
                      "your system.  Some of it may be mounted under %s\n\n") +
                    iutil.getSysroot() + msg)
                self._window.append(text)
                return True
        else:
            if flags.automatedInstall and self.data.reboot.action in [
                    KS_REBOOT, KS_SHUTDOWN
            ]:
                log.info("No Linux partitions found.")
                text = TextWidget(
                    _("You don't have any Linux partitions.  Rebooting.\n"))
                self._window.append(text)
                # should probably wait a few seconds to show the message
                time.sleep(5)
                iutil.execWithRedirect("systemctl", ["--no-wall", "reboot"])
            else:
                if not flags.imageInstall:
                    msg = _(
                        "The system will reboot automatically when you exit"
                        " from the shell.\n")
                else:
                    msg = ""
            text = TextWidget(
                _("You don't have any Linux partitions. %s\n") % msg)
            self._window.append(text)
            return True

        if rootmounted and not self.readOnly:
            self.storage.make_mtab()
            try:
                makeResolvConf(iutil.getSysroot())
            except (OSError, IOError) as e:
                log.error("Error making resolv.conf: %s", e)
            text = TextWidget(
                _("Your system is mounted under the %s directory.") %
                iutil.getSysroot())
            self._window.append(text)

        # create /etc/fstab in ramdisk so it's easier to work with RO mounted fs
        makeFStab()

        # run %post if we've mounted everything
        if rootmounted and not self.readOnly and flags.automatedInstall:
            runPostScripts(self.data.scripts)

        return True
コード例 #22
0
ファイル: time_spoke.py プロジェクト: mudler/anaconda
 def refresh(self, args=None):
     NormalTUISpoke.refresh(self, args)
     summary = self._summary_text()
     self._window += [TextWidget(summary), ""]
     return True
コード例 #23
0
 def _prep(i, w):
     """ Do some format magic for display. """
     num = TextWidget("%2d)" % (i + 1))
     return ColumnWidget([(4, [num]), (None, [w])], 1)
コード例 #24
0
 def _prep(i, w):
     """ make everything look nice """
     number = TextWidget("%2d)" % (i + 1))
     return ColumnWidget([(4, [number]), (None, [w])], 1)