Example #1
0
 def dbus_name_test(self):
     """Test DBus path."""
     self.assertEqual(get_dbus_name(), "")
     self.assertEqual(get_dbus_name("a"), "a")
     self.assertEqual(get_dbus_name("a", "b"), "a.b")
     self.assertEqual(get_dbus_name("a", "b", "c"), "a.b.c")
     self.assertEqual(get_dbus_name("org", "freedesktop", "DBus"), "org.freedesktop.DBus")
Example #2
0
 def dbus_name_test(self):
     """Test DBus path."""
     self.assertEqual(get_dbus_name(), "")
     self.assertEqual(get_dbus_name("a"), "a")
     self.assertEqual(get_dbus_name("a", "b"), "a.b")
     self.assertEqual(get_dbus_name("a", "b", "c"), "a.b.c")
     self.assertEqual(get_dbus_name("org", "freedesktop", "DBus"),
                      "org.freedesktop.DBus")
Example #3
0
    def add_addon_modules(self):
        """Add the addon modules."""
        dbus = DBus.get_dbus_proxy()
        names = dbus.ListActivatableNames()
        prefix = get_dbus_name(*ADDONS_NAMESPACE)

        for service_name in names:
            if service_name.startswith(prefix):
                self.add_module(service_name)
Example #4
0
def dbus_error(error_name, namespace):
    """Define decorated class as a DBus error.

    The decorated exception class will be mapped to a DBus error.

    :param error_name: a DBus name of the error
    :param namespace: a sequence of strings
    :return: a decorator
    """
    return map_error(get_dbus_name(*namespace, error_name))
Example #5
0
def dbus_error(error_name, namespace):
    """Define decorated class as a DBus error.

    The decorated exception class will be mapped to a DBus error.

    :param error_name: a DBus name of the error
    :param namespace: a sequence of strings
    :return: a decorator
    """
    return map_error(get_dbus_name(*namespace, error_name))
Example #6
0
    def __init__(self, namespace, basename=None):
        """Create an identifier.

        :param namespace: a sequence of strings
        :param basename: a string with the base name or None
        """
        if basename:
            namespace = (*namespace, basename)

        self._namespace = namespace
        self._name = get_dbus_name(*namespace)
        self._path = get_dbus_path(*namespace)
Example #7
0
    def __init__(self, namespace, basename=None):
        """Create an identifier.

        :param namespace: a sequence of strings
        :param basename: a string with the base name or None
        """
        if basename:
            namespace = (*namespace, basename)

        self._namespace = namespace
        self._name = get_dbus_name(*namespace)
        self._path = get_dbus_path(*namespace)
Example #8
0
    def add_addon_modules(self):
        """Add the addon modules."""
        dbus = DBus.get_dbus_proxy()
        names = dbus.ListActivatableNames()
        prefix = get_dbus_name(*ADDONS_NAMESPACE)

        for service_name in names:
            if service_name.startswith(prefix):
                # Get the object path.
                namespace = get_namespace_from_name(service_name)
                object_path = get_dbus_path(*namespace)

                # Add the observer.
                observer = DBus.get_observer(service_name, object_path)
                self._module_observers.append(observer)
Example #9
0
    def _find_addons(self):
        """Find additional modules."""
        modules = []

        if not self._addons_enabled:
            return modules

        dbus = self._message_bus.get_dbus_proxy()
        names = dbus.ListActivatableNames()
        prefix = get_dbus_name(*ADDONS_NAMESPACE)

        for service_name in names:
            if not service_name.startswith(prefix):
                continue

            log.debug("Found %s.", service_name)
            modules.append(
                ModuleObserver(self._message_bus, service_name, is_addon=True))

        return modules