示例#1
0
    def runDebug(self, exc_info):
        if flags.can_touch_runtime_system("switch console") \
                and self._intf_tty_num != 1:
            iutil.vtActivate(1)

        iutil.eintr_retry_call(os.open, "/dev/console",
                               os.O_RDWR)  # reclaim stdin
        iutil.eintr_ignore(os.dup2, 0, 1)  # reclaim stdout
        iutil.eintr_ignore(os.dup2, 0, 2)  # reclaim stderr
        #                      ^
        #                      |
        #                      +------ dup2 is magic, I tells ya!

        # bring back the echo
        import termios
        si = sys.stdin.fileno()
        attr = termios.tcgetattr(si)
        attr[3] = attr[3] & termios.ECHO
        termios.tcsetattr(si, termios.TCSADRAIN, attr)

        print("\nEntering debugger...")
        print("Use 'continue' command to quit the debugger and get back to "\
              "the main window")
        import pdb
        pdb.post_mortem(exc_info.stack)

        if flags.can_touch_runtime_system("switch console") \
                and self._intf_tty_num != 1:
            iutil.vtActivate(self._intf_tty_num)
示例#2
0
    def runDebug(self, exc_info):
        if flags.can_touch_runtime_system("switch console") and self._intf_tty_num != 1:
            iutil.vtActivate(1)

        iutil.eintr_retry_call(os.open, "/dev/console", os.O_RDWR)  # reclaim stdin
        iutil.eintr_ignore(os.dup2, 0, 1)  # reclaim stdout
        iutil.eintr_ignore(os.dup2, 0, 2)  # reclaim stderr
        #                      ^
        #                      |
        #                      +------ dup2 is magic, I tells ya!

        # bring back the echo
        import termios

        si = sys.stdin.fileno()
        attr = termios.tcgetattr(si)
        attr[3] = attr[3] & termios.ECHO
        termios.tcsetattr(si, termios.TCSADRAIN, attr)

        print("\nEntering debugger...")
        print("Use 'continue' command to quit the debugger and get back to " "the main window")
        import pdb

        pdb.post_mortem(exc_info.stack)

        if flags.can_touch_runtime_system("switch console") and self._intf_tty_num != 1:
            iutil.vtActivate(self._intf_tty_num)
示例#3
0
    def initialize(self):
        NormalSpoke.initialize(self)
        self.initialize_start()

        # set X keyboard defaults
        # - this needs to be done early in spoke initialization so that
        #   the spoke status does not show outdated keyboard selection
        keyboard.set_x_keyboard_defaults(self.data, self._xkl_wrapper)

        # make sure the x_layouts list has at least one keyboard layout
        if not self.data.keyboard.x_layouts:
            self.data.keyboard.x_layouts.append(DEFAULT_KEYBOARD)

        self._add_dialog = AddLayoutDialog(self.data)
        self._add_dialog.initialize()

        if flags.can_touch_runtime_system("hide runtime keyboard configuration "
                                          "warning", touch_live=True):
            self.builder.get_object("warningBox").hide()

        # We want to store layouts' names but show layouts as
        # 'language (description)'.
        layoutColumn = self.builder.get_object("layoutColumn")
        layoutRenderer = self.builder.get_object("layoutRenderer")
        override_cell_property(layoutColumn, layoutRenderer, "text", _show_layout,
                                            self._xkl_wrapper)

        self._store = self.builder.get_object("addedLayoutStore")
        self._add_data_layouts()

        self._selection = self.builder.get_object("layoutSelection")

        self._switching_dialog = ConfigureSwitchingDialog(self.data)
        self._switching_dialog.initialize()

        self._layoutSwitchLabel = self.builder.get_object("layoutSwitchLabel")

        if not flags.can_touch_runtime_system("test X layouts", touch_live=True):
            # Disable area for testing layouts as we cannot make
            # it work without modifying runtime system

            widgets = [self.builder.get_object("testingLabel"),
                       self.builder.get_object("testingWindow"),
                       self.builder.get_object("layoutSwitchLabel")]

            # Use testingLabel's text to explain why this part is not
            # sensitive.
            widgets[0].set_text(_("Testing layouts configuration not "
                                  "available."))

            for widget in widgets:
                widget.set_sensitive(False)

        hubQ.send_not_ready(self.__class__.__name__)
        hubQ.send_message(self.__class__.__name__,
                          _("Getting list of layouts..."))
        threadMgr.add(AnacondaThread(name=THREAD_KEYBOARD_INIT,
                                     target=self._wait_ready))
示例#4
0
    def _set_keyboard_defaults(self, locale):
        """
        Set default keyboard settings (layouts, layout switching).

        :param locale: locale string (see localization.LANGCODE_RE)
        :type locale: str
        :return: list of preferred keyboard layouts
        :rtype: list of strings
        :raise InvalidLocaleSpec: if an invalid locale is given (see
                                  localization.LANGCODE_RE)

        """

        #remove all X layouts that are not valid X layouts (unsupported)
        #from the ksdata
        #XXX: could go somewhere else, but we need X running and we have
        #     XklWrapper instance here
        for layout in self.data.keyboard.x_layouts:
            if not self._xklwrapper.is_valid_layout(layout):
                self.data.keyboard.x_layouts.remove(layout)

        if self.data.keyboard.x_layouts:
            #do not add layouts if there are any specified in the kickstart
            return

        layouts = localization.get_locale_keyboards(locale)
        if layouts:
            # take the first locale (with highest rank) from the list and
            # store it normalized
            new_layouts = [keyboard.normalize_layout_variant(layouts[0])]
            if not langtable.supports_ascii(layouts[0]):
                # does not support typing ASCII chars, append the default layout
                new_layouts.append(DEFAULT_KEYBOARD)
        else:
            log.error("Failed to get layout for chosen locale '%s'", locale)
            new_layouts = [DEFAULT_KEYBOARD]

        self.data.keyboard.x_layouts = new_layouts
        if flags.can_touch_runtime_system("replace runtime X layouts",
                                          touch_live=True):
            self._xklwrapper.replace_layouts(new_layouts)

        if len(new_layouts) >= 2 and not self.data.keyboard.switch_options:
            #initialize layout switching if needed
            self.data.keyboard.switch_options = ["grp:alt_shift_toggle"]

            if flags.can_touch_runtime_system("init layout switching",
                                              touch_live=True):
                self._xklwrapper.set_switching_options(
                    ["grp:alt_shift_toggle"])
                # activate the language-default layout instead of the additional
                # one
                self._xklwrapper.activate_default_layout()
示例#5
0
    def initialize(self):
        NormalSpoke.initialize(self)
        self._add_dialog = AddLayoutDialog(self.data)
        self._add_dialog.initialize()

        if flags.can_touch_runtime_system(
                "hide runtime keyboard configuration "
                "warning", touch_live=True):
            self.builder.get_object("warningBox").hide()

        # We want to store layouts' names but show layouts as
        # 'language (description)'.
        layoutColumn = self.builder.get_object("layoutColumn")
        layoutRenderer = self.builder.get_object("layoutRenderer")
        override_cell_property(layoutColumn, layoutRenderer, "text",
                               _show_layout, self._xkl_wrapper)

        self._store = self.builder.get_object("addedLayoutStore")
        self._add_data_layouts()

        self._selection = self.builder.get_object("layoutSelection")

        self._switching_dialog = ConfigureSwitchingDialog(self.data)
        self._switching_dialog.initialize()

        self._layoutSwitchLabel = self.builder.get_object("layoutSwitchLabel")

        if not flags.can_touch_runtime_system("test X layouts",
                                              touch_live=True):
            # Disable area for testing layouts as we cannot make
            # it work without modifying runtime system

            widgets = [
                self.builder.get_object("testingLabel"),
                self.builder.get_object("testingWindow"),
                self.builder.get_object("layoutSwitchLabel")
            ]

            # Use testingLabel's text to explain why this part is not
            # sensitive.
            widgets[0].set_text(
                _("Testing layouts configuration not "
                  "available."))

            for widget in widgets:
                widget.set_sensitive(False)

        hubQ.send_not_ready(self.__class__.__name__)
        hubQ.send_message(self.__class__.__name__,
                          _("Getting list of layouts..."))
        threadMgr.add(
            AnacondaThread(name=THREAD_KEYBOARD_INIT, target=self._wait_ready))
示例#6
0
def set_x_keyboard_defaults(localization_proxy, xkl_wrapper):
    """
    Set default keyboard settings (layouts, layout switching).

    :param localization_proxy: DBus proxy of the localization module or None
    :type ksdata: object instance
    :param xkl_wrapper: XklWrapper instance
    :type xkl_wrapper: object instance
    :raise InvalidLocaleSpec: if an invalid locale is given (see
                              localization.LANGCODE_RE)
    """
    x_layouts = localization_proxy.XLayouts
    # remove all X layouts that are not valid X layouts (unsupported)
    valid_layouts = []
    for layout in x_layouts:
        if xkl_wrapper.is_valid_layout(layout):
            valid_layouts.append(layout)
    localization_proxy.SetXLayouts(valid_layouts)

    if valid_layouts:
        # do not add layouts if there are any specified in the kickstart
        # (the x_layouts list comes from kickstart)
        return

    locale = localization_proxy.Language
    layouts = localization.get_locale_keyboards(locale)
    if layouts:
        # take the first locale (with highest rank) from the list and
        # store it normalized
        new_layouts = [normalize_layout_variant(layouts[0])]
        if not langtable.supports_ascii(layouts[0]):
            # does not support typing ASCII chars, append the default layout
            new_layouts.append(DEFAULT_KEYBOARD)
    else:
        log.error("Failed to get layout for chosen locale '%s'", locale)
        new_layouts = [DEFAULT_KEYBOARD]

    localization_proxy.SetXLayouts(new_layouts)
    if can_touch_runtime_system("replace runtime X layouts", touch_live=True):
        xkl_wrapper.replace_layouts(new_layouts)

    if len(new_layouts) >= 2 and not localization_proxy.LayoutSwitchOptions:
        # initialize layout switching if needed
        localization_proxy.SetLayoutSwitchOptions(["grp:alt_shift_toggle"])

        if can_touch_runtime_system("init layout switching", touch_live=True):
            xkl_wrapper.set_switching_options(["grp:alt_shift_toggle"])
            # activate the language-default layout instead of the additional
            # one
            xkl_wrapper.activate_default_layout()
示例#7
0
    def _set_keyboard_defaults(self, locale):
        """
        Set default keyboard settings (layouts, layout switching).

        :param locale: locale string (see localization.LANGCODE_RE)
        :type locale: str
        :return: list of preferred keyboard layouts
        :rtype: list of strings
        :raise InvalidLocaleSpec: if an invalid locale is given (see
                                  localization.LANGCODE_RE)

        """

        #remove all X layouts that are not valid X layouts (unsupported)
        #from the ksdata
        #XXX: could go somewhere else, but we need X running and we have
        #     XklWrapper instance here
        for layout in self.data.keyboard.x_layouts:
            if not self._xklwrapper.is_valid_layout(layout):
                self.data.keyboard.x_layouts.remove(layout)

        if self.data.keyboard.x_layouts:
            #do not add layouts if there are any specified in the kickstart
            return

        layouts = localization.get_locale_keyboards(locale)
        if layouts:
            # take the first locale (with highest rank) from the list and
            # store it normalized
            new_layouts = [keyboard.normalize_layout_variant(layouts[0])]
            if not langtable.supports_ascii(layouts[0]):
                # does not support typing ASCII chars, append the default layout
                new_layouts.append(DEFAULT_KEYBOARD)
        else:
            log.error("Failed to get layout for chosen locale '%s'", locale)
            new_layouts = [DEFAULT_KEYBOARD]

        self.data.keyboard.x_layouts = new_layouts
        if flags.can_touch_runtime_system("replace runtime X layouts", touch_live=True):
            self._xklwrapper.replace_layouts(new_layouts)

        if len(new_layouts) >= 2 and not self.data.keyboard.switch_options:
            #initialize layout switching if needed
            self.data.keyboard.switch_options = ["grp:alt_shift_toggle"]

            if flags.can_touch_runtime_system("init layout switching", touch_live=True):
                self._xklwrapper.set_switching_options(["grp:alt_shift_toggle"])
                # activate the language-default layout instead of the additional
                # one
                self._xklwrapper.activate_default_layout()
示例#8
0
def set_x_keyboard_defaults(ksdata, xkl_wrapper):
    """
    Set default keyboard settings (layouts, layout switching).

    :param ksdata: kickstart instance
    :type ksdata: object instance
    :param xkl_wrapper: XklWrapper instance
    :type xkl_wrapper: object instance
    :raise InvalidLocaleSpec: if an invalid locale is given (see
                              localization.LANGCODE_RE)
    """
    locale = ksdata.lang.lang

    # remove all X layouts that are not valid X layouts (unsupported)
    for layout in ksdata.keyboard.x_layouts:
        if not xkl_wrapper.is_valid_layout(layout):
            ksdata.keyboard.x_layouts.remove(layout)

    if ksdata.keyboard.x_layouts:
        # do not add layouts if there are any specified in the kickstart
        # (the x_layouts list comes from kickstart)
        return

    layouts = localization.get_locale_keyboards(locale)
    if layouts:
        # take the first locale (with highest rank) from the list and
        # store it normalized
        new_layouts = [normalize_layout_variant(layouts[0])]
        if not langtable.supports_ascii(layouts[0]):
            # does not support typing ASCII chars, append the default layout
            new_layouts.append(DEFAULT_KEYBOARD)
    else:
        log.error("Failed to get layout for chosen locale '%s'", locale)
        new_layouts = [DEFAULT_KEYBOARD]

    ksdata.keyboard.x_layouts = new_layouts
    if can_touch_runtime_system("replace runtime X layouts", touch_live=True):
        xkl_wrapper.replace_layouts(new_layouts)

    if len(new_layouts) >= 2 and not ksdata.keyboard.switch_options:
        # initialize layout switching if needed
        ksdata.keyboard.switch_options = ["grp:alt_shift_toggle"]

        if can_touch_runtime_system("init layout switching", touch_live=True):
            xkl_wrapper.set_switching_options(["grp:alt_shift_toggle"])
            # activate the language-default layout instead of the additional
            # one
            xkl_wrapper.activate_default_layout()
示例#9
0
    def input(self, args, key):
        """Override input so that we can launch the VNC password spoke"""

        try:
            keyid = int(key) - 1
            if 0 <= keyid < len(self._choices):
                choice = self._choices[keyid]
                if choice == _(USETEXT):
                    self._usevnc = False
                else:
                    self._usevnc = True
                    newspoke = VNCPassSpoke(self.app, self.data, self.storage,
                                            self.payload, self.instclass)
                    self.app.switch_screen_modal(newspoke)

                self.apply()
                self.close()
            return INPUT_PROCESSED
        except ValueError:
            pass

        # TRANSLATORS: 'q' to quit
        if key.lower() == C_('TUI|Spoke Navigation', 'q'):
            d = YesNoDialog(self.app, _(self.app.quit_message))
            self.app.switch_screen_modal(d)
            if d.answer:
                iutil.ipmi_report(IPMI_ABORTED)
                if can_touch_runtime_system("Quit and Reboot"):
                    execWithRedirect("systemctl", ["--no-wall", "reboot"])
                else:
                    exit(1)
        else:
            return key
示例#10
0
    def input(self, args, key):
        """Override input so that we can launch the VNC password spoke"""

        try:
            keyid = int(key) - 1
            if 0 <= keyid < len(self._choices):
                choice = self._choices[keyid]
                if choice == _(USETEXT):
                    self._usevnc = False
                else:
                    self._usevnc = True
                    newspoke = VNCPassSpoke(self.app, self.data, self.storage,
                                            self.payload, self.instclass)
                    self.app.switch_screen_modal(newspoke)

                self.apply()
                self.close()
            return INPUT_PROCESSED
        except ValueError:
            pass

        if key.lower() == _('q'):
            d = YesNoDialog(self.app, _(self.app.quit_message))
            self.app.switch_screen_modal(d)
            if d.answer:
                from pyanaconda.flags import can_touch_runtime_system
                if can_touch_runtime_system("reboot"):
                    execWithRedirect("systemctl", ["--no-wall", "reboot"])
                else:
                    sys.exit(1)
        else:
            return key
示例#11
0
    def refresh(self):
        self._shown = True

        #update the displayed time
        self._update_datetime_timer_id = GLib.timeout_add_seconds(1,
                                                    self._update_datetime)
        self._start_updating_timer_id = None

        if is_valid_timezone(self.data.timezone.timezone):
            self._tzmap.set_timezone(self.data.timezone.timezone)

        self._update_datetime()

        has_active_network = nm.nm_is_connected()
        if not has_active_network:
            self._show_no_network_warning()
        else:
            self.clear_info()
            gtk_call_once(self._config_dialog.refresh_servers_state)

        if flags.can_touch_runtime_system("get NTP service state"):
            ntp_working = has_active_network and iutil.service_running(NTP_SERVICE)
        else:
            ntp_working = not self.data.timezone.nontp

        self._ntpSwitch.set_active(ntp_working)
示例#12
0
 def completed(self):
     """ Check whether this spoke is complete or not. Do an additional
         check if we're installing from CD/DVD, since a network connection
         should not be required in this case.
     """
     return (not can_touch_runtime_system("require network connection")
             or nm_activated_devices())
示例#13
0
def setupLoggingFromOpts(options):
    if (options.debug or options.updateSrc) and not options.loglevel:
        # debugging means debug logging if an explicit level hasn't been st
        options.loglevel = "debug"

    if options.loglevel and options.loglevel in anaconda_log.logLevelMap:
        log.info("Switching logging level to %s", options.loglevel)
        level = anaconda_log.logLevelMap[options.loglevel]
        anaconda_log.logger.loglevel = level
        anaconda_log.setHandlersLevel(log, level)
        storage_log = logging.getLogger("storage")
        anaconda_log.setHandlersLevel(storage_log, level)
        packaging_log = logging.getLogger("packaging")
        anaconda_log.setHandlersLevel(packaging_log, level)

    if can_touch_runtime_system("syslog setup"):
        if options.syslog:
            anaconda_log.logger.updateRemote(options.syslog)

    if options.remotelog:
        try:
            host, port = options.remotelog.split(":", 1)
            port = int(port)
            anaconda_log.logger.setup_remotelog(host, port)
        except ValueError:
            log.error("Could not setup remotelog with %s", options.remotelog)
示例#14
0
    def input(self, args, key):
        """Override input so that we can launch the VNC password spoke"""

        try:
            keyid = int(key) - 1
            if 0 <= keyid < len(self._choices):
                choice = self._choices[keyid]
                if choice == _(USETEXT):
                    self._usevnc = False
                else:
                    self._usevnc = True
                    newspoke = VNCPassSpoke(self.app, self.data, self.storage,
                                            self.payload, self.instclass)
                    self.app.switch_screen_modal(newspoke)

                self.apply()
                self.close()
            return INPUT_PROCESSED
        except ValueError:
            pass

        # TRANSLATORS: 'q' to quit
        if key.lower() == C_('TUI|Spoke Navigation', 'q'):
            d = YesNoDialog(self.app, _(self.app.quit_message))
            self.app.switch_screen_modal(d)
            if d.answer:
                ipmi_abort(scripts=self.data.scripts)
                if can_touch_runtime_system("Quit and Reboot"):
                    execWithRedirect("systemctl", ["--no-wall", "reboot"])
                else:
                    sys.exit(1)
        else:
            return super(AskVNCSpoke, self).input(args, key)
示例#15
0
 def completed(self):
     """ Check whether this spoke is complete or not. Do an additional
         check if we're installing from CD/DVD, since a network connection
         should not be required in this case.
     """
     return (not can_touch_runtime_system("require network connection")
             or nm.nm_activated_devices())
示例#16
0
def setupLoggingFromOpts(options):
    if (options.debug or options.updateSrc) and not options.loglevel:
        # debugging means debug logging if an explicit level hasn't been st
        options.loglevel = "debug"

    if options.loglevel and options.loglevel in anaconda_log.logLevelMap:
        log.info("Switching logging level to %s", options.loglevel)
        level = anaconda_log.logLevelMap[options.loglevel]
        anaconda_log.logger.loglevel = level
        anaconda_log.setHandlersLevel(log, level)
        storage_log = logging.getLogger("storage")
        anaconda_log.setHandlersLevel(storage_log, level)
        packaging_log = logging.getLogger("packaging")
        anaconda_log.setHandlersLevel(packaging_log, level)

    if can_touch_runtime_system("syslog setup"):
        if options.syslog:
            anaconda_log.logger.updateRemote(options.syslog)

    if options.remotelog:
        try:
            host, port = options.remotelog.split(":", 1)
            port = int(port)
            anaconda_log.logger.setup_remotelog(host, port)
        except ValueError:
            log.error("Could not setup remotelog with %s", options.remotelog)
示例#17
0
    def _addLayout(self, store, name):
        # first try to add the layout
        if flags.can_touch_runtime_system("add runtime X layout", touch_live=True):
            self._xkl_wrapper.add_layout(name)

        # valid layout, append it to the store
        store.append([name])
示例#18
0
def setup_logging_from_options(options):
    """Configure logging according to Anaconda command line/boot options.

    :param options: Anaconda command line/boot options
    """
    if (options.debug or options.updateSrc) and not options.loglevel:
        # debugging means debug logging if an explicit level hasn't been st
        options.loglevel = "debug"

    if options.loglevel and options.loglevel in anaconda_logging.logLevelMap:
        log.info("Switching logging level to %s", options.loglevel)
        level = anaconda_logging.logLevelMap[options.loglevel]
        anaconda_logging.logger.loglevel = level
        anaconda_logging.setHandlersLevel(log, level)
        storage_log = get_storage_logger()
        anaconda_logging.setHandlersLevel(storage_log, level)
        packaging_log = get_packaging_logger()
        anaconda_logging.setHandlersLevel(packaging_log, level)

    if can_touch_runtime_system("syslog setup"):
        if options.syslog:
            anaconda_logging.logger.updateRemote(options.syslog)

    if options.remotelog:
        try:
            host, port = options.remotelog.split(":", 1)
            port = int(port)
            anaconda_logging.logger.setup_remotelog(host, port)
        except ValueError:
            log.error("Could not setup remotelog with %s", options.remotelog)
示例#19
0
    def refresh(self):
        self._shown = True

        # update the displayed time
        self._update_datetime_timer = Timer()
        self._update_datetime_timer.timeout_sec(1, self._update_datetime)
        self._start_updating_timer = None

        kickstart_timezone = self._timezone_module.proxy.Timezone

        if is_valid_timezone(kickstart_timezone):
            self._tzmap.set_timezone(kickstart_timezone)
            time.tzset()

        self._update_datetime()

        has_active_network = nm.nm_is_connected()
        if not has_active_network:
            self._show_no_network_warning()
        else:
            self.clear_info()
            gtk_call_once(self._config_dialog.refresh_servers_state)

        if flags.can_touch_runtime_system("get NTP service state"):
            ntp_working = has_active_network and util.service_running(
                NTP_SERVICE)
        else:
            ntp_working = self._timezone_module.proxy.NTPEnabled

        self._ntpSwitch.set_active(ntp_working)
示例#20
0
def setup_logging_from_options(options):
    """Configure logging according to Anaconda command line/boot options.

    :param options: Anaconda command line/boot options
    """
    if (options.debug or options.updateSrc) and not options.loglevel:
        # debugging means debug logging if an explicit level hasn't been st
        options.loglevel = "debug"

    if options.loglevel and options.loglevel in anaconda_logging.logLevelMap:
        log.info("Switching logging level to %s", options.loglevel)
        level = anaconda_logging.logLevelMap[options.loglevel]
        anaconda_logging.logger.loglevel = level
        anaconda_logging.setHandlersLevel(log, level)
        storage_log = get_storage_logger()
        anaconda_logging.setHandlersLevel(storage_log, level)
        packaging_log = get_packaging_logger()
        anaconda_logging.setHandlersLevel(packaging_log, level)

    if can_touch_runtime_system("syslog setup"):
        if options.syslog:
            anaconda_logging.logger.updateRemote(options.syslog)

    if options.remotelog:
        try:
            host, port = options.remotelog.split(":", 1)
            port = int(port)
            anaconda_logging.logger.setup_remotelog(host, port)
        except ValueError:
            log.error("Could not setup remotelog with %s", options.remotelog)
示例#21
0
    def refresh(self):
        self._shown = True

        #update the displayed time
        self._update_datetime_timer_id = GLib.timeout_add_seconds(
            1, self._update_datetime)
        self._start_updating_timer_id = None

        if is_valid_timezone(self.data.timezone.timezone):
            self._tzmap.set_timezone(self.data.timezone.timezone)

        self._update_datetime()

        has_active_network = nm.nm_is_connected()
        if not has_active_network:
            self._show_no_network_warning()
        else:
            self.clear_info()
            gtk_call_once(self._config_dialog.refresh_servers_state)

        if flags.can_touch_runtime_system("get NTP service state"):
            ntp_working = has_active_network and iutil.service_running(
                NTP_SERVICE)
        else:
            ntp_working = not self.data.timezone.nontp

        self._ntpSwitch.set_active(ntp_working)
示例#22
0
    def _addLayout(self, store, name):
        # first try to add the layout
        if flags.can_touch_runtime_system("add runtime X layout"):
            self._xkl_wrapper.add_layout(name)

        # valid layout, append it to the store
        store.append([name])
示例#23
0
    def run(self):
        self.window.show()
        rc = self.window.run()
        self.window.hide()

        #OK clicked
        if rc == 1:
            new_servers = list()

            for row in self._serversStore:
                #if server checked
                if row[2]:
                    new_servers.append(row[0])

            if flags.can_touch_runtime_system(
                    "save NTP servers configuration"):
                ntp.save_servers_to_config(new_servers)
                iutil.restart_service(NTP_SERVICE)

        #Cancel clicked, window destroyed...
        else:
            self._epoch_lock.acquire()
            self._epoch += 1
            self._epoch_lock.release()

            self._initialize_store_from_config()

        return rc
    def run(self):
        self.window.show()
        rc = self.window.run()
        self.window.hide()

        #OK clicked
        if rc == 1:
            new_servers = list()

            for row in self._serversStore:
                #if server checked
                if row[2]:
                    new_servers.append(row[0])

            if flags.can_touch_runtime_system("save NTP servers configuration"):
                ntp.save_servers_to_config(new_servers)
                iutil.restart_service(NTP_SERVICE)

        #Cancel clicked, window destroyed...
        else:
            self._epoch_lock.acquire()
            self._epoch += 1
            self._epoch_lock.release()

            self._initialize_store_from_config()

        return rc
示例#25
0
    def _set_keyboard_defaults(self, lang_name, country):
        """
        Set default keyboard settings (layouts, layout switching).

        :param lang_name: name of the selected language (e.g. "Czech")

        """

        #remove all X layouts that are not valid X layouts (unsupported)
        #from the ksdata
        #XXX: could go somewhere else, but we need X running and we have
        #     XklWrapper instance here
        for layout in self.data.keyboard.x_layouts:
            if not self._xklwrapper.is_valid_layout(layout):
                self.data.keyboard.x_layouts.remove(layout)

        if self.data.keyboard.x_layouts:
            #do not add layouts if there are any specified in the kickstart
            return

        #get language name without any additional specifications
        #e.g. 'English (United States)' -> 'English'
        lang_name = lang_name.split()[0]

        default_layout = self._xklwrapper.get_default_lang_country_layout(lang_name,
                                                                          country)
        if default_layout:
            new_layouts = [default_layout]
        else:
            new_layouts = ["us"]

        checkbutton = self.builder.get_object("setKeyboardCheckButton")
        if not checkbutton.get_active() and "us" not in new_layouts:
            #user doesn't want only the language-default layout, prepend
            #'English (US)' layout
            new_layouts.insert(0, "us")

        self.data.keyboard.x_layouts = new_layouts
        if flags.can_touch_runtime_system("replace runtime X layouts"):
            self._xklwrapper.replace_layouts(new_layouts)

        if len(new_layouts) >= 2 and not self.data.keyboard.switch_options:
            #initialize layout switching if needed
            self.data.keyboard.switch_options = ["grp:alt_shift_toggle"]

            if flags.can_touch_runtime_system("init layout switching"):
                self._xklwrapper.set_switching_options(["grp:alt_shift_toggle"])
示例#26
0
    def initialize(self):
        NormalSpoke.initialize(self)
        self._add_dialog = AddLayoutDialog(self.data)
        self._add_dialog.initialize()

        if flags.can_touch_runtime_system("hide runtime keyboard configuration "
                                          "warning", touch_live=True):
            self.builder.get_object("warningBox").hide()

        # We want to store layouts' names but show layouts as
        # 'language (description)'.
        layoutColumn = self.builder.get_object("layoutColumn")
        layoutRenderer = self.builder.get_object("layoutRenderer")
        layoutColumn.set_cell_data_func(layoutRenderer, _show_layout,
                                            self._xkl_wrapper)

        self._store = self.builder.get_object("addedLayoutStore")
        self._add_data_layouts()

        self._selection = self.builder.get_object("layoutSelection")

        self._switching_dialog = ConfigureSwitchingDialog(self.data)
        self._switching_dialog.initialize()

        self._layoutSwitchLabel = self.builder.get_object("layoutSwitchLabel")

        if not flags.can_touch_runtime_system("test X layouts", touch_live=True):
            # Disable area for testing layouts as we cannot make
            # it work without modifying runtime system

            widgets = [self.builder.get_object("testingLabel"),
                       self.builder.get_object("testingWindow"),
                       self.builder.get_object("layoutSwitchLabel")]

            # Use testingLabel's text to explain why this part is not
            # sensitive.
            widgets[0].set_text(_("Testing layouts configuration not "
                                  "available."))

            for widget in widgets:
                widget.set_sensitive(False)

        hubQ.send_not_ready(self.__class__.__name__)
        hubQ.send_message(self.__class__.__name__,
                          _("Getting list of layouts..."))
        threadMgr.add(AnacondaThread(name=THREAD_KEYBOARD_INIT,
                                     target=self._wait_ready))
示例#27
0
 def completed(self):
     """ Check whether this spoke is complete or not. Do an additional
         check if we're installing from CD/DVD, since a network connection
         should not be required in this case.
     """
     localinst = bool(self.data.method.method in ["cdrom", "harddrive"])
     return (not can_touch_runtime_system("require network connection")
             or nm.nm_activated_devices() or localinst)
示例#28
0
 def completed(self):
     """ Check whether this spoke is complete or not. Do an additional
         check if we're installing from CD/DVD, since a network connection
         should not be required in this case.
     """
     localinst = bool(self.data.method.method in ["cdrom", "harddrive"])
     return (not can_touch_runtime_system("require network connection")
             or nm.nm_activated_devices() or localinst)
示例#29
0
    def on_ntp_switched(self, switch, *args):
        if switch.get_active():
            #turned ON
            if not flags.can_touch_runtime_system("start NTP service"):
                #cannot touch runtime system, not much to do here
                return

            if not nm.nm_is_connected():
                self._show_no_network_warning()
                switch.set_active(False)
                return
            else:
                self.clear_info()

                working_server = self._config_dialog.working_server
                if working_server is None:
                    self._show_no_ntp_server_warning()
                else:
                    #we need a one-time sync here, because chronyd would not change
                    #the time as drastically as we need
                    ntp.one_time_sync_async(working_server)

            ret = iutil.start_service(NTP_SERVICE)
            self._set_date_time_setting_sensitive(False)

            #if starting chronyd failed and chronyd is not running,
            #set switch back to OFF
            if (ret != 0) and not iutil.service_running(NTP_SERVICE):
                switch.set_active(False)

        else:
            #turned OFF
            if not flags.can_touch_runtime_system("stop NTP service"):
                #cannot touch runtime system, nothing to do here
                return

            self._set_date_time_setting_sensitive(True)
            ret = iutil.stop_service(NTP_SERVICE)

            #if stopping chronyd failed and chronyd is running,
            #set switch back to ON
            if (ret != 0) and iutil.service_running(NTP_SERVICE):
                switch.set_active(True)

            self.clear_info()
    def on_ntp_switched(self, switch, *args):
        if switch.get_active():
            #turned ON
            if not flags.can_touch_runtime_system("start NTP service"):
                #cannot touch runtime system, not much to do here
                return

            if not nm.nm_is_connected():
                self._show_no_network_warning()
                switch.set_active(False)
                return
            else:
                self.clear_info()

                working_server = self._config_dialog.working_server
                if working_server is None:
                    self._show_no_ntp_server_warning()
                else:
                    #we need a one-time sync here, because chronyd would not change
                    #the time as drastically as we need
                    ntp.one_time_sync_async(working_server)

            ret = iutil.start_service(NTP_SERVICE)
            self._set_date_time_setting_sensitive(False)

            #if starting chronyd failed and chronyd is not running,
            #set switch back to OFF
            if (ret != 0) and not iutil.service_running(NTP_SERVICE):
                switch.set_active(False)

        else:
            #turned OFF
            if not flags.can_touch_runtime_system("stop NTP service"):
                #cannot touch runtime system, nothing to do here
                return

            self._set_date_time_setting_sensitive(True)
            ret = iutil.stop_service(NTP_SERVICE)

            #if stopping chronyd failed and chronyd is running,
            #set switch back to ON
            if (ret != 0) and iutil.service_running(NTP_SERVICE):
                switch.set_active(True)

            self.clear_info()
示例#31
0
    def __init__(self):
        try:
            self._connection = safe_dbus.get_new_system_connection()
        except GLib.GError as e:
            if can_touch_runtime_system("raise GLib.GError", touch_live=True):
                raise

            log.error("Failed to get safe_dbus connection: %s", e)
            self._connection = None
示例#32
0
    def __init__(self):
        try:
            self._connection = safe_dbus.get_new_system_connection()
        except GLib.GError as e:
            if can_touch_runtime_system("raise GLib.GError", touch_live=True):
                raise

            log.error("Failed to get safe_dbus connection: %s", e)
            self._connection = None
    def __init__(self):
        # pylint: disable-msg=E0611
        from gi.repository import GdkX11

        #initialize Xkl-related stuff
        display = GdkX11.x11_get_default_xdisplay()
        self._engine = Xkl.Engine.get_instance(display)

        self._rec = Xkl.ConfigRec()
        if not self._rec.get_from_server(self._engine):
            raise XklWrapperError("Failed to get configuration from server")

        #X is probably initialized to the 'us' layout without any variant and
        #since we want to add layouts with variants we need the layouts and
        #variants lists to have the same length. Add "" padding to variants.
        #See docstring of the add_layout method for details.
        diff = len(self._rec.layouts) - len(self._rec.variants)
        if diff > 0 and flags.can_touch_runtime_system("activate layouts"):
            self._rec.set_variants(self._rec.variants + (diff * [""]))
            if not self._rec.activate(self._engine):
                # failed to activate layouts given e.g. by a kickstart (may be
                # invalid)
                lay_var_str = ",".join(map(_join_layout_variant,
                                           self._rec.layouts,
                                           self._rec.variants))
                log.error("Failed to activate layouts: '%s', "
                          "falling back to default 'us'" % lay_var_str)
                self._rec.set_layouts(["us"])
                self._rec.set_variants([""])

                if not self._rec.activate(self._engine):
                    # failed to activate even the default "us" layout, something
                    # is really wrong
                    raise XklWrapperError("Failed to initialize layouts")

        #needed also for Gkbd.KeyboardDrawingDialog
        self.configreg = Xkl.ConfigRegistry.get_instance(self._engine)
        self.configreg.load(False)

        self._language_keyboard_variants = dict()
        self._country_keyboard_variants = dict()
        self._switching_options = list()

        #we want to display layouts as 'language (description)'
        self.name_to_show_str = dict()

        #we want to display layout switching options as e.g. "Alt + Shift" not
        #as "grp:alt_shift_toggle"
        self.switch_to_show_str = dict()

        #this might take quite a long time
        self.configreg.foreach_language(self._get_language_variants, None)
        self.configreg.foreach_country(self._get_country_variants, None)

        #'grp' means that we want layout (group) switching options
        self.configreg.foreach_option('grp', self._get_switch_option, None)
示例#34
0
    def _removeLayout(self, store, itr):
        """
        Remove the layout specified by store iterator from the store and
        X runtime configuration.

        """

        if flags.can_touch_runtime_system("remove runtime X layout", touch_live=True):
            self._xkl_wrapper.remove_layout(store[itr][0])
        store.remove(itr)
示例#35
0
    def _removeLayout(self, store, itr):
        """
        Remove the layout specified by store iterator from the store and
        X runtime configuration.

        """

        if flags.can_touch_runtime_system("remove runtime X layout"):
            self._xkl_wrapper.remove_layout(store[itr][0])
        store.remove(itr)
示例#36
0
    def initialize(self):
        NormalSpoke.initialize(self)

        if flags.can_touch_runtime_system(
                "hide runtime keyboard configuration "
                "warning", touch_live=True):
            self.builder.get_object("warningBox").hide()

        # We want to store layouts' names but show layouts as
        # 'language (description)'.
        layoutColumn = self.builder.get_object("layoutColumn")
        layoutRenderer = self.builder.get_object("layoutRenderer")
        layoutColumn.set_cell_data_func(layoutRenderer, _show_layout,
                                        self._xkl_wrapper)

        self._store = self.builder.get_object("addedLayoutStore")
        self._add_data_layouts()

        self._switching_dialog = ConfigureSwitchingDialog(self.data)
        self._switching_dialog.initialize()

        self._layoutSwitchLabel = self.builder.get_object("layoutSwitchLabel")

        if not flags.can_touch_runtime_system("test X layouts",
                                              touch_live=True):
            # Disable area for testing layouts as we cannot make
            # it work without modifying runtime system

            widgets = [
                self.builder.get_object("testingLabel"),
                self.builder.get_object("testingWindow"),
                self.builder.get_object("layoutSwitchLabel")
            ]

            # Use testingLabel's text to explain why this part is not
            # sensitive.
            widgets[0].set_text(
                _("Testing layouts configuration not "
                  "available."))

            for widget in widgets:
                widget.set_sensitive(False)
示例#37
0
    def _initialize(self):
        for day in xrange(1, 32):
            self.add_to_store(self._daysStore, day)

        for i in xrange(1, 13):
            #a bit hacky way, but should return the translated string
            #TODO: how to handle language change? Clear and populate again?
            month = datetime.date(2000, i, 1).strftime('%B')
            self.add_to_store(self._monthsStore, month)
            self._months_nums[month] = i

        for year in xrange(1990, 2051):
            self.add_to_store(self._yearsStore, year)

        cities = set()
        xlated_regions = ((region, get_xlated_timezone(region))
                          for region in self._regions_zones.iterkeys())
        for region, xlated in sorted(xlated_regions, cmp=_compare_regions):
            self.add_to_store_xlated(self._regionsStore, region, xlated)
            for city in self._regions_zones[region]:
                cities.add((city, get_xlated_timezone(city)))

        for city, xlated in sorted(cities, cmp=_compare_cities):
            self.add_to_store_xlated(self._citiesStore, city, xlated)

        if self._radioButton24h.get_active():
            self._set_amPm_part_sensitive(False)

        self._update_datetime_timer_id = None
        if is_valid_timezone(self.data.timezone.timezone):
            self._set_timezone(self.data.timezone.timezone)
        elif not flags.flags.automatedInstall:
            log.warning(
                "%s is not a valid timezone, falling back to default (%s)",
                self.data.timezone.timezone, DEFAULT_TZ)
            self._set_timezone(DEFAULT_TZ)
            self.data.timezone.timezone = DEFAULT_TZ

        if not flags.can_touch_runtime_system("modify system time and date"):
            self._set_date_time_setting_sensitive(False)

        self._config_dialog = NTPconfigDialog(self.data)
        self._config_dialog.initialize()

        time_init_thread = threadMgr.get(constants.THREAD_TIME_INIT)
        if time_init_thread is not None:
            hubQ.send_message(self.__class__.__name__,
                              _("Restoring hardware time..."))
            threadMgr.wait(constants.THREAD_TIME_INIT)

        hubQ.send_ready(self.__class__.__name__, False)
示例#38
0
    def __init__(self):
        from gi.repository import GdkX11, Xkl

        self._xkl = Xkl

        #initialize Xkl-related stuff
        display = GdkX11.x11_get_default_xdisplay()
        self._engine = Xkl.Engine.get_instance(display)

        self._rec = Xkl.ConfigRec()
        if not self._rec.get_from_server(self._engine):
            raise XklWrapperError("Failed to get configuration from server")

        #X is probably initialized to the 'us' layout without any variant and
        #since we want to add layouts with variants we need the layouts and
        #variants lists to have the same length. Add "" padding to variants.
        #See docstring of the add_layout method for details.
        diff = len(self._rec.layouts) - len(self._rec.variants)
        if diff > 0 and flags.can_touch_runtime_system("activate layouts"):
            self._rec.set_variants(self._rec.variants + (diff * [""]))
            if not self._rec.activate(self._engine):
                # failed to activate layouts given e.g. by a kickstart (may be
                # invalid)
                lay_var_str = ",".join(
                    map(_join_layout_variant, self._rec.layouts,
                        self._rec.variants))
                log.error(
                    "Failed to activate layouts: '%s', "
                    "falling back to default %s", lay_var_str,
                    DEFAULT_KEYBOARD)
                self._rec.set_layouts([DEFAULT_KEYBOARD])
                self._rec.set_variants([""])

                if not self._rec.activate(self._engine):
                    # failed to activate even the default layout, something is
                    # really wrong
                    raise XklWrapperError("Failed to initialize layouts")

        #needed also for Gkbd.KeyboardDrawingDialog
        self.configreg = Xkl.ConfigRegistry.get_instance(self._engine)
        self.configreg.load(False)

        self._layout_infos = dict()
        self._switch_opt_infos = dict()

        #this might take quite a long time
        self.configreg.foreach_language(self._get_language_variants, None)
        self.configreg.foreach_country(self._get_country_variants, None)

        #'grp' means that we want layout (group) switching options
        self.configreg.foreach_option('grp', self._get_switch_option, None)
    def _initialize(self):
        for day in xrange(1, 32):
            self.add_to_store(self._daysStore, day)

        for i in xrange(1, 13):
            #a bit hacky way, but should return the translated string
            #TODO: how to handle language change? Clear and populate again?
            month = datetime.date(2000, i, 1).strftime('%B')
            self.add_to_store(self._monthsStore, month)
            self._months_nums[month] = i

        for year in xrange(1990, 2051):
            self.add_to_store(self._yearsStore, year)

        cities = set()
        xlated_regions = ((region, get_xlated_timezone(region))
                          for region in self._regions_zones.iterkeys())
        for region, xlated in sorted(xlated_regions, cmp=_compare_regions):
            self.add_to_store_xlated(self._regionsStore, region, xlated)
            for city in self._regions_zones[region]:
                cities.add((city, get_xlated_timezone(city)))

        for city, xlated in sorted(cities, cmp=_compare_cities):
            self.add_to_store_xlated(self._citiesStore, city, xlated)

        if self._radioButton24h.get_active():
            self._set_amPm_part_sensitive(False)

        self._update_datetime_timer_id = None
        if is_valid_timezone(self.data.timezone.timezone):
            self._set_timezone(self.data.timezone.timezone)
        elif not flags.flags.automatedInstall:
            log.warning("%s is not a valid timezone, falling back to default (%s)",
                        self.data.timezone.timezone, DEFAULT_TZ)
            self._set_timezone(DEFAULT_TZ)
            self.data.timezone.timezone = DEFAULT_TZ

        if not flags.can_touch_runtime_system("modify system time and date"):
            self._set_date_time_setting_sensitive(False)

        self._config_dialog = NTPconfigDialog(self.data)
        self._config_dialog.initialize()

        time_init_thread = threadMgr.get(constants.THREAD_TIME_INIT)
        if time_init_thread is not None:
            hubQ.send_message(self.__class__.__name__,
                             _("Restoring hardware time..."))
            threadMgr.wait(constants.THREAD_TIME_INIT)

        hubQ.send_ready(self.__class__.__name__, False)
示例#40
0
    def runDebug(self, exc_info):
        if flags.can_touch_runtime_system("switch console") \
                and self._intf_tty_num != 1:
            iutil.vtActivate(1)

        pidfl = "/tmp/vncshell.pid"
        if os.path.exists(pidfl) and os.path.isfile(pidfl):
            pf = open(pidfl, "r")
            for pid in pf.readlines():
                if not int(pid) == os.getpid():
                    os.kill(int(pid), signal.SIGKILL)
            pf.close()

        iutil.eintr_retry_call(os.open, "/dev/console",
                               os.O_RDWR)  # reclaim stdin
        iutil.eintr_retry_call(os.dup2, 0, 1)  # reclaim stdout
        iutil.eintr_retry_call(os.dup2, 0, 2)  # reclaim stderr
        #                          ^
        #                          |
        #                          +------ dup2 is magic, I tells ya!

        # bring back the echo
        import termios
        si = sys.stdin.fileno()
        attr = termios.tcgetattr(si)
        attr[3] = attr[3] & termios.ECHO
        termios.tcsetattr(si, termios.TCSADRAIN, attr)

        print("\nEntering debugger...")
        print("Use 'continue' command to quit the debugger and get back to "\
              "the main window")
        import pdb
        pdb.post_mortem(exc_info.stack)

        if flags.can_touch_runtime_system("switch console") \
                and self._intf_tty_num != 1:
            iutil.vtActivate(self._intf_tty_num)
    def initialize(self):
        NormalSpoke.initialize(self)

        if flags.can_touch_runtime_system("hide runtime keyboard configuration "
                                          "warning"):
            self.builder.get_object("warningBox").hide()

        # We want to store layouts' names but show layouts as
        # 'language (description)'.
        layoutColumn = self.builder.get_object("layoutColumn")
        layoutRenderer = self.builder.get_object("layoutRenderer")
        layoutColumn.set_cell_data_func(layoutRenderer, _show_layout,
                                            self._xkl_wrapper)

        self._store = self.builder.get_object("addedLayoutStore")
        self._add_data_layouts()

        self._switching_dialog = ConfigureSwitchingDialog(self.data)
        self._switching_dialog.initialize()

        self._layoutSwitchLabel = self.builder.get_object("layoutSwitchLabel")

        if not flags.can_touch_runtime_system("test X layouts"):
            # Disable area for testing layouts as we cannot make
            # it work without modifying runtime system

            widgets = [self.builder.get_object("testingLabel"),
                       self.builder.get_object("testingWindow"),
                       self.builder.get_object("layoutSwitchLabel")]

            # Use testingLabel's text to explain why this part is not
            # sensitive.
            widgets[0].set_text(_("Testing layouts configuration not "
                                  "available."))

            for widget in widgets:
                widget.set_sensitive(False)
示例#42
0
    def initialize(self):
        NormalSpoke.initialize(self)
        self._daysStore = self.builder.get_object("days")
        self._monthsStore = self.builder.get_object("months")
        self._yearsStore = self.builder.get_object("years")
        self._regionsStore = self.builder.get_object("regions")
        self._citiesStore = self.builder.get_object("cities")
        self._tzmap = self.builder.get_object("tzmap")

        # we need to know it the new value is the same as previous or not
        self._old_region = None
        self._old_city = None

        self._regionCombo = self.builder.get_object("regionCombobox")
        self._cityCombo = self.builder.get_object("cityCombobox")
        self._monthCombo = self.builder.get_object("monthCombobox")
        self._dayCombo = self.builder.get_object("dayCombobox")
        self._yearCombo = self.builder.get_object("yearCombobox")

        self._daysFilter = self.builder.get_object("daysFilter")
        self._daysFilter.set_visible_func(self.existing_date, None)

        self._citiesFilter = self.builder.get_object("citiesFilter")
        self._citiesFilter.set_visible_func(self.city_in_region, None)

        self._hoursLabel = self.builder.get_object("hoursLabel")
        self._minutesLabel = self.builder.get_object("minutesLabel")
        self._amPmUp = self.builder.get_object("amPmUpButton")
        self._amPmDown = self.builder.get_object("amPmDownButton")
        self._amPmLabel = self.builder.get_object("amPmLabel")
        self._radioButton24h = self.builder.get_object("timeFormatRB")

        self._ntpSwitch = self.builder.get_object("networkTimeSwitch")

        self._regions_zones = get_all_regions_and_timezones()

        self._months_nums = dict()

        # Set the initial sensitivity of the AM/PM toggle based on the time-type selected
        self._radioButton24h.emit("toggled")

        if not flags.can_touch_runtime_system("modify system time and date"):
            self._set_date_time_setting_sensitive(False)

        self._config_dialog = NTPconfigDialog(self.data)
        self._config_dialog.initialize()

        threadMgr.add(AnacondaThread(name=constants.THREAD_DATE_TIME,
                                     target=self._initialize))
    def runDebug(self, exc_info):
        if flags.can_touch_runtime_system("switch console") \
                and self._intf_tty_num != 1:
            iutil.vtActivate(1)

        pidfl = "/tmp/vncshell.pid"
        if os.path.exists(pidfl) and os.path.isfile(pidfl):
            pf = open(pidfl, "r")
            for pid in pf.readlines():
                if not int(pid) == os.getpid():
                    os.kill(int(pid), signal.SIGKILL)
            pf.close()

        os.open("/dev/console", os.O_RDWR)   # reclaim stdin
        os.dup2(0, 1)                        # reclaim stdout
        os.dup2(0, 2)                        # reclaim stderr
        #   ^
        #   |
        #   +------ dup2 is magic, I tells ya!

        # bring back the echo
        import termios
        si = sys.stdin.fileno()
        attr = termios.tcgetattr(si)
        attr[3] = attr[3] & termios.ECHO
        termios.tcsetattr(si, termios.TCSADRAIN, attr)

        print("\nEntering debugger...")
        print("Use 'continue' command to quit the debugger and get back to "\
              "the main window")
        import pdb
        pdb.post_mortem(exc_info.stack)

        if flags.can_touch_runtime_system("switch console") \
                and self._intf_tty_num != 1:
            iutil.vtActivate(self._intf_tty_num)
示例#44
0
    def __init__(self):
        #initialize Xkl-related stuff
        display = GdkX11.x11_get_default_xdisplay()
        self._engine = Xkl.Engine.get_instance(display)

        self._rec = Xkl.ConfigRec()
        if not self._rec.get_from_server(self._engine):
            raise XklWrapperError("Failed to get configuration from server")

        #X is probably initialized to the 'us' layout without any variant and
        #since we want to add layouts with variants we need the layouts and
        #variants lists to have the same length. Add "" padding to variants.
        #See docstring of the add_layout method for details.
        diff = len(self._rec.layouts) - len(self._rec.variants)
        if diff > 0 and flags.can_touch_runtime_system("activate layouts"):
            self._rec.set_variants(self._rec.variants + (diff * [""]))
            if not self._rec.activate(self._engine):
                # failed to activate layouts given e.g. by a kickstart (may be
                # invalid)
                lay_var_str = ",".join(map(join_layout_variant,
                                           self._rec.layouts,
                                           self._rec.variants))
                log.error("Failed to activate layouts: '%s', "
                          "falling back to default %s", lay_var_str, DEFAULT_KEYBOARD)
                self._rec.set_layouts([DEFAULT_KEYBOARD])
                self._rec.set_variants([""])

                if not self._rec.activate(self._engine):
                    # failed to activate even the default layout, something is
                    # really wrong
                    raise XklWrapperError("Failed to initialize layouts")

        #needed also for Gkbd.KeyboardDrawingDialog
        self.configreg = Xkl.ConfigRegistry.get_instance(self._engine)
        self.configreg.load(False)

        self._layout_infos = dict()
        self._layout_infos_lock = threading.RLock()
        self._switch_opt_infos = dict()
        self._switch_opt_infos_lock = threading.RLock()

        #this might take quite a long time
        self.configreg.foreach_language(self._get_language_variants, None)
        self.configreg.foreach_country(self._get_country_variants, None)

        #'grp' means that we want layout (group) switching options
        self.configreg.foreach_option('grp', self._get_switch_option, None)
示例#45
0
 def open_config_file(self, config_path=None):
     """Try to open an existing config file."""
     with self._lock:
         # Don't load the user interaction config from
         # default path if no path is specified in image or
         # directory installation modes.
         # The config would be taken from the host system,
         # which is certainly not what we would want to happen.
         # But load the config if a path is specified,
         # so that it is possible to hide spokes in
         # image and directory installation modes.
         if config_path is None and can_touch_runtime_system(msg="write user interaction config file",
                                                             touch_live=True):
             config_path = CONFIG_FILE_PATH
         if config_path and os.path.exists(config_path):
             log.info("parsing existing user interaction config file in %s", config_path)
             with open(config_path, "rt") as f:
                 self._config.read_file(f)
示例#46
0
 def input(self, args, key):
     """Override input so that we can launch the VNC password spoke"""
     if self._container.process_user_input(key):
         self.apply()
         return InputState.PROCESSED_AND_CLOSE
     else:
         # TRANSLATORS: 'q' to quit
         if key.lower() == C_('TUI|Spoke Navigation', 'q'):
             d = YesNoDialog(_(u"Do you really want to quit?"))
             ScreenHandler.push_screen_modal(d)
             if d.answer:
                 ipmi_abort(scripts=self.data.scripts)
                 if can_touch_runtime_system("Quit and Reboot"):
                     execWithRedirect("systemctl", ["--no-wall", "reboot"])
                 else:
                     sys.exit(1)
         else:
             return super().input(args, key)
示例#47
0
    def on_up_clicked(self, button):
        if not self._selection.count_selected_rows():
            return

        (store, cur) = self._selection.get_selected()
        prev = store.iter_previous(cur)
        if not prev:
            return

        store.swap(cur, prev)
        if flags.can_touch_runtime_system("reorder runtime X layouts", touch_live=True):
            self._flush_layouts_to_X()

        if not store.iter_previous(cur):
            #layout is first in the list (set as default), activate it
            self._xkl_wrapper.activate_default_layout()

        self._selection.emit("changed")
示例#48
0
 def open_config_file(self, config_path=None):
     """Try to open an existing config file."""
     with self._lock:
         # Don't load the user interaction config from
         # default path if no path is specified in image or
         # directory installation modes.
         # The config would be taken from the host system,
         # which is certainly not what we would want to happen.
         # But load the config if a path is specified,
         # so that it is possible to hide spokes in
         # image and directory installation modes.
         if config_path is None and can_touch_runtime_system(msg="write user interaction config file",
                                                             touch_live=True):
             config_path = CONFIG_FILE_PATH
         if config_path and os.path.exists(config_path):
             log.info("parsing existing user interaction config file in %s", config_path)
             with open(config_path, "rt") as f:
                 self._config.read_file(f)
示例#49
0
    def _save_system_time(self):
        """
        Returning False from this method removes the timer that would
        otherwise call it again and again.

        """

        self._start_updating_timer_id = None

        if not flags.can_touch_runtime_system("save system time"):
            return False

        month = self._get_combo_selection(self._monthCombo)[0]
        if not month:
            return False

        year = self._get_combo_selection(self._yearCombo)[0]
        if not year:
            return False

        hours = int(self._hoursLabel.get_text())
        if not self._radioButton24h.get_active():
            hours = self._to_24h(hours, self._amPmLabel.get_text())

        minutes = int(self._minutesLabel.get_text())

        day = self._get_combo_selection(self._dayCombo)[0]
        #day may be None if there is no such in the selected year and month
        if day:
            isys.set_system_date_time(year,
                                      month,
                                      day,
                                      hours,
                                      minutes,
                                      tz=self._tz)

        #start the timer only when the spoke is shown
        if self._shown and not self._update_datetime_timer_id:
            self._update_datetime_timer_id = GLib.timeout_add_seconds(
                1, self._update_datetime)

        #run only once (after first 2 seconds of inactivity)
        return False
示例#50
0
def _get_proxy(bus_type=Gio.BusType.SYSTEM,
               proxy_flags=Gio.DBusProxyFlags.NONE,
               info=None,
               name="org.freedesktop.NetworkManager",
               object_path="/org/freedesktop/NetworkManager",
               interface_name="org.freedesktop.NetworkManager",
               cancellable=None):
    try:
        proxy = Gio.DBusProxy.new_for_bus_sync(bus_type, proxy_flags, info,
                                               name, object_path,
                                               interface_name, cancellable)
    except GError as e:
        if can_touch_runtime_system("raise GLib.GError", touch_live=True):
            raise

        log.error("_get_proxy failed: %s", e)
        proxy = None

    return proxy
示例#51
0
文件: askvnc.py 项目: jaymzh/anaconda
 def input(self, args, key):
     """Override input so that we can launch the VNC password spoke"""
     if self._container.process_user_input(key):
         self.apply()
         self.close()
         return InputState.PROCESSED
     else:
         # TRANSLATORS: 'q' to quit
         if key.lower() == C_('TUI|Spoke Navigation', 'q'):
             d = YesNoDialog(_(u"Do you really want to quit?"))
             ScreenHandler.push_screen_modal(d)
             if d.answer:
                 ipmi_abort(scripts=self.data.scripts)
                 if can_touch_runtime_system("Quit and Reboot"):
                     execWithRedirect("systemctl", ["--no-wall", "reboot"])
                 else:
                     sys.exit(1)
         else:
             return super(AskVNCSpoke, self).input(args, key)
示例#52
0
    def _save_system_time(self):
        """
        Returning False from this method removes the timer that would
        otherwise call it again and again.

        """

        if not flags.can_touch_runtime_system("save system time"):
            return False

        month = self._get_combo_selection(self._monthCombo)
        if not month:
            return False
        month = self._months_nums[month]

        year_str = self._get_combo_selection(self._yearCombo)
        if not year_str:
            return False
        year = int(year_str)

        hours = int(self._hoursLabel.get_text())
        if not self._radioButton24h.get_active():
            hours = self._to_24h(hours, self._amPmLabel.get_text())

        minutes = int(self._minutesLabel.get_text())

        day = self._get_combo_selection(self._dayCombo)
        #day may be None if there is no such in the selected year and month
        if day:
            day = int(day)
            seconds = datetime.datetime.now().second
            os.system("date -s '%0.2d/%0.2d/%0.4d %0.2d:%0.2d:%0.2d'" %
                      (month, day, year, hours, minutes, seconds))

        #start the timer only when the spoke is shown
        if self._update_datetime_timer_id is not None:
            self._update_datetime_timer_id = GLib.timeout_add_seconds(
                1, self._update_datetime)

        #run only once (after first 2 seconds of inactivity)
        return False
    def _save_system_time(self):
        """
        Returning False from this method removes the timer that would
        otherwise call it again and again.

        """

        if not flags.can_touch_runtime_system("save system time"):
            return False

        month = self._get_combo_selection(self._monthCombo)
        if not month:
            return False
        month = self._months_nums[month]

        year_str = self._get_combo_selection(self._yearCombo)
        if not year_str:
            return False
        year = int(year_str)

        hours = int(self._hoursLabel.get_text())
        if not self._radioButton24h.get_active():
            hours = self._to_24h(hours, self._amPmLabel.get_text())

        minutes = int(self._minutesLabel.get_text())

        day = self._get_combo_selection(self._dayCombo)
        #day may be None if there is no such in the selected year and month
        if day:
            day = int(day)
            seconds = datetime.datetime.now().second
            os.system("date -s '%0.2d/%0.2d/%0.4d %0.2d:%0.2d:%0.2d'" %
                                (month, day, year, hours, minutes, seconds))

        #start the timer only when the spoke is shown
        if self._update_datetime_timer_id is not None:
            self._update_datetime_timer_id = GLib.timeout_add_seconds(1,
                                                        self._update_datetime)

        #run only once (after first 2 seconds of inactivity)
        return False
示例#54
0
    def on_down_clicked(self, button):
        if not self._selection.count_selected_rows():
            return

        (store, cur) = self._selection.get_selected()

        #if default layout (first in the list) changes we need to activate it
        activate_default = not store.iter_previous(cur)

        nxt = store.iter_next(cur)
        if not nxt:
            return

        store.swap(cur, nxt)
        if flags.can_touch_runtime_system("reorder runtime X layouts", touch_live=True):
            self._flush_layouts_to_X()

        if activate_default:
            self._xkl_wrapper.activate_default_layout()

        self._selection.emit("changed")
示例#55
0
    def run(self):
        self.window.show()
        rc = self.window.run()
        self.window.hide()

        #OK clicked
        if rc == 1:
            new_pools, new_servers = self.pools_servers

            if flags.can_touch_runtime_system("save NTP servers configuration"):
                ntp.save_servers_to_config(new_pools, new_servers)
                util.restart_service(NTP_SERVICE)

        #Cancel clicked, window destroyed...
        else:
            self._epoch_lock.acquire()
            self._epoch += 1
            self._epoch_lock.release()

            self._initialize_store_from_config()

        return rc
示例#56
0
    def _save_system_time(self):
        """
        Returning False from this method removes the timer that would
        otherwise call it again and again.

        """

        self._start_updating_timer_id = None

        if not flags.can_touch_runtime_system("save system time"):
            return False

        month = self._get_combo_selection(self._monthCombo)[0]
        if not month:
            return False

        year = self._get_combo_selection(self._yearCombo)[0]
        if not year:
            return False

        hours = int(self._hoursLabel.get_text())
        if not self._radioButton24h.get_active():
            hours = self._to_24h(hours, self._amPmLabel.get_text())

        minutes = int(self._minutesLabel.get_text())

        day = self._get_combo_selection(self._dayCombo)[0]
        #day may be None if there is no such in the selected year and month
        if day:
            isys.set_system_date_time(year, month, day, hours, minutes, tz=self._tz)

        #start the timer only when the spoke is shown
        if self._shown and not self._update_datetime_timer_id:
            self._update_datetime_timer_id = GLib.timeout_add_seconds(1,
                                                        self._update_datetime)

        #run only once (after first 2 seconds of inactivity)
        return False
示例#57
0
def _get_proxy(bus_type=Gio.BusType.SYSTEM,
               proxy_flags=Gio.DBusProxyFlags.NONE,
               info=None,
               name="org.freedesktop.NetworkManager",
               object_path="/org/freedesktop/NetworkManager",
               interface_name="org.freedesktop.NetworkManager",
               cancellable=None):
    try:
        proxy = Gio.DBusProxy.new_for_bus_sync(bus_type,
                                               proxy_flags,
                                               info,
                                               name,
                                               object_path,
                                               interface_name,
                                               cancellable)
    except GLib.GError as e:
        if can_touch_runtime_system("raise GLib.GError", touch_live=True):
            raise

        log.error("_get_proxy failed: %s", e)
        proxy = None

    return proxy