Exemple #1
0
    def layouts_variants(self):
        try:
            layouts = safe_dbus.get_property_sync(LOCALED_SERVICE,
                                                  LOCALED_OBJECT_PATH,
                                                  LOCALED_IFACE, "X11Layout",
                                                  self._connection)
        except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError):
            # no value for the property
            log.error("Failed to get the value for the systemd-localed's "
                      "X11Layout property")
            return [""]

        try:
            variants = safe_dbus.get_property_sync(LOCALED_SERVICE,
                                                   LOCALED_OBJECT_PATH,
                                                   LOCALED_IFACE, "X11Variant",
                                                   self._connection)
        except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError):
            # no value for the property
            log.error("Failed to get the value for the systemd-localed's "
                      "X11Variant property")
            variants = []

        # returned GVariants are unpacked to tuples with single elements
        # containing comma-separated values
        layouts = layouts[0].split(",")

        if variants:
            variants = variants[0].split(",")

        # if there are more layouts than variants, empty strings should be appended
        diff = len(layouts) - len(variants)
        variants.extend(diff * [""])

        # if there are more variants than layouts, throw the trailing ones away
        variants = variants[:len(layouts)]

        # map can be used with multiple lists and works like zipWith (Haskell)
        return map(join_layout_variant, layouts, variants)
Exemple #2
0
    def options(self):
        try:
            options = safe_dbus.get_property_sync(LOCALED_SERVICE,
                                                  LOCALED_OBJECT_PATH,
                                                  LOCALED_IFACE, "X11Options",
                                                  self._connection)
        except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError):
            # no value for the property
            log.error("Failed to get the value for the systemd-localed's "
                      "X11Options property")
            return ""

        # returned GVariant is unpacked to a tuple with a single element
        return options[0]
Exemple #3
0
    def layouts_variants(self):
        try:
            layouts = safe_dbus.get_property_sync(LOCALED_SERVICE,
                                                  LOCALED_OBJECT_PATH,
                                                  LOCALED_IFACE, "X11Layout",
                                                  self._connection)
        except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError):
            # no value for the property
            log.error("Failed to get the value for the systemd-localed's "
                      "X11Layout property")
            return [""]

        try:
            variants = safe_dbus.get_property_sync(LOCALED_SERVICE,
                                                   LOCALED_OBJECT_PATH,
                                                   LOCALED_IFACE, "X11Variant",
                                                   self._connection)
        except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError):
            # no value for the property
            log.error("Failed to get the value for the systemd-localed's "
                      "X11Variant property")
            variants = []

        # returned GVariants are unpacked to tuples with single elements
        # containing comma-separated values
        layouts = layouts[0].split(",")

        if variants:
            variants = variants[0].split(",")

        # if there are more layouts than variants, empty strings should be appended
        diff = len(layouts) - len(variants)
        variants.extend(diff * [""])
        return [
            join_layout_variant(layout, variant)
            for layout, variant in zip(layouts, variants)
        ]
Exemple #4
0
    def options(self):
        try:
            options = safe_dbus.get_property_sync(LOCALED_SERVICE,
                                                  LOCALED_OBJECT_PATH,
                                                  LOCALED_IFACE,
                                                  "X11Options",
                                                  self._connection)
        except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError):
            # no value for the property
            log.error("Failed to get the value for the systemd-localed's "
                      "X11Options property")
            return ""

        # returned GVariant is unpacked to a tuple with a single element
        return options[0]
Exemple #5
0
    def layouts_variants(self):
        try:
            layouts = safe_dbus.get_property_sync(LOCALED_SERVICE,
                                                  LOCALED_OBJECT_PATH,
                                                  LOCALED_IFACE,
                                                  "X11Layout",
                                                  self._connection)
        except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError):
            # no value for the property
            log.error("Failed to get the value for the systemd-localed's "
                      "X11Layout property")
            return [""]

        try:
            variants = safe_dbus.get_property_sync(LOCALED_SERVICE,
                                                   LOCALED_OBJECT_PATH,
                                                   LOCALED_IFACE,
                                                   "X11Variant",
                                                   self._connection)
        except (safe_dbus.DBusPropertyError, safe_dbus.DBusCallError):
            # no value for the property
            log.error("Failed to get the value for the systemd-localed's "
                      "X11Variant property")
            variants = []

        # returned GVariants are unpacked to tuples with single elements
        # containing comma-separated values
        layouts = layouts[0].split(",")

        if variants:
            variants = variants[0].split(",")

        # if there are more layouts than variants, empty strings should be appended
        diff = len(layouts) - len(variants)
        variants.extend(diff * [""])
        return [join_layout_variant(layout, variant) for layout, variant in zip(layouts, variants)]