Exemplo n.º 1
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 = getpass.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]))
Exemplo n.º 2
0
    def refresh(self, args=None):
        StandaloneTUISpoke.refresh(self, args)

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

        return True
    def refresh(self, args=None):
        StandaloneTUISpoke.refresh(self, args)

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

        return True
Exemplo n.º 4
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)
Exemplo n.º 5
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
Exemplo n.º 6
0
 def _prep(i, w):
     """ make everything look nice """
     number = TextWidget("%2d)" % (i + 1))
     return ColumnWidget([(4, [number]), (None, [w])], 1)
Exemplo n.º 7
0
 def _prep(i, w):
     """ Do some format magic for display. """
     num = TextWidget("%2d)" % (i + 1))
     return ColumnWidget([(4, [num]), (None, [w])], 1)
Exemplo n.º 8
0
    def refresh(self, args=None):
        NormalTUISpoke.refresh(self, args)

        if self._root:
            try:
                mountExistingSystem(self.storage.fsset,
                                    self._root.device,
                                    readOnly=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\nIf "
                          "you would like to make your system the root "
                          "environment, 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.turnOnSwap()
                    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.makeMtab()
            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
Exemplo n.º 9
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
Exemplo n.º 10
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
Exemplo n.º 11
0
 def refresh(self, args=None):
     NormalTUISpoke.refresh(self, args)
     summary = self._summary_text()
     self._window += [TextWidget(summary), ""]
     return True
Exemplo n.º 12
0
 def _prep(i, w):
     number = TextWidget("%2d)" % (i + 1))
     return ColumnWidget([(4, [number]), (None, [w])], 1)