def dbus_path_test(self):
     """Test DBus path."""
     self.assertEqual(get_dbus_path(), "/")
     self.assertEqual(get_dbus_path("a"), "/a")
     self.assertEqual(get_dbus_path("a", "b"), "/a/b")
     self.assertEqual(get_dbus_path("a", "b", "c"), "/a/b/c")
     self.assertEqual(get_dbus_path("org", "freedesktop", "DBus"), "/org/freedesktop/DBus")
Beispiel #2
0
 def dbus_path_test(self):
     """Test DBus path."""
     self.assertEqual(get_dbus_path(), "/")
     self.assertEqual(get_dbus_path("a"), "/a")
     self.assertEqual(get_dbus_path("a", "b"), "/a/b")
     self.assertEqual(get_dbus_path("a", "b", "c"), "/a/b/c")
     self.assertEqual(get_dbus_path("org", "freedesktop", "DBus"),
                      "/org/freedesktop/DBus")
Beispiel #3
0
    def add_module(self, service_name):
        """Add a modules with the given service name."""
        # 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)
Beispiel #4
0
    def get_object_path(namespace):
        """Get the unique object path in the given namespace.

        This method is not thread safe for now.

        :param namespace: a sequence of names
        :return: a DBus path of a task
        """
        task_number = TaskInterface._task_counter
        TaskInterface._task_counter += 1
        return get_dbus_path(*namespace, "Tasks", str(task_number))
Beispiel #5
0
    def get_object_path(namespace):
        """Get the unique object path in the given namespace.

        This method is not thread safe for now.

        :param namespace: a sequence of names
        :return: a DBus path of a task
        """
        task_number = TaskInterface._task_counter
        TaskInterface._task_counter += 1
        return get_dbus_path(*namespace, "Tasks", str(task_number))
Beispiel #6
0
    def get_object_path(namespace):
        """Get the unique object path in the given namespace.

        This method is not thread safe for now.

        :param namespace: a sequence of names
        :return: a DBus path of an object
        """
        user_number = UserInterface._user_counter
        UserInterface._user_counter += 1
        return get_dbus_path(*namespace, "User", str(user_number))
    def get_object_path(namespace):
        """Get the unique object path in the given namespace.

        This method is not thread safe for now.

        :param namespace: a sequence of names
        :return: a DBus path of a device tree
        """
        tree_number = DeviceTreeInterface._tree_counter
        DeviceTreeInterface._tree_counter += 1
        return get_dbus_path(*namespace, "DeviceTree", str(tree_number))
Beispiel #8
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)
Beispiel #9
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)
Beispiel #10
0
    def __init__(self, message_bus, service_name, is_addon=False):
        """Creates a module observer.

        :param message_bus: a message bus
        :param service_name: a DBus name of a service
        :param is_addon: is the observed module an addon?
        """
        super().__init__(message_bus, service_name)
        self._proxy = None
        self._is_addon = is_addon
        self._namespace = get_namespace_from_name(service_name)
        self._object_path = get_dbus_path(*self._namespace)
Beispiel #11
0
    def _generate_object_path(self):
        """Generate a unique object path.

        This method is not thread safe.

        :return: a unique object path
        """
        self._counter += 1

        return get_dbus_path(
            *self._namespace,
            self._basename,
            str(self._counter)
        )
Beispiel #12
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)