def __init__(self, conn=None, object_path=None, bus_name=None): """Constructor. Either conn or bus_name is required; object_path is also required. :Parameters: `conn` : dbus.connection.Connection or None The connection on which to export this object. If None, use the Bus associated with the given ``bus_name``. If there is no ``bus_name`` either, the object is not initially available on any Connection. For backwards compatibility, if an instance of dbus.service.BusName is passed as the first parameter, this is equivalent to passing its associated Bus as ``conn``, and passing the BusName itself as ``bus_name``. `object_path` : str or None A D-Bus object path at which to make this Object available immediately. If this is not None, a `conn` or `bus_name` must also be provided. `bus_name` : dbus.service.BusName or None Represents a well-known name claimed by this process. A reference to the BusName object will be held by this Object, preventing the name from being released during this Object's lifetime (unless it's released manually). """ if object_path is not None: validate_object_path(object_path) if isinstance(conn, BusName): # someone's using the old API; don't gratuitously break them bus_name = conn conn = bus_name.get_bus() elif conn is None: if bus_name is not None: # someone's using the old API but naming arguments, probably conn = bus_name.get_bus() #: Either an object path, None or _MANY self._object_path = None #: Either a dbus.connection.Connection, None or _MANY self._connection = None #: A list of tuples (Connection, object path, False) where the False #: is for future expansion (to support fallback paths) self._locations = [] #: Lock protecting `_locations`, `_connection` and `_object_path` self._locations_lock = threading.Lock() #: True if this is a fallback object handling a whole subtree. self._fallback = False self._name = bus_name if conn is None and object_path is not None: raise TypeError('If object_path is given, either conn or bus_name ' 'is required') if conn is not None and object_path is not None: self.add_to_connection(conn, object_path)
def profile_name_valid(p): try: dbus.validate_bus_name("com." + p) dbus.validate_object_path("/" + p) except (TypeError, ValueError): return False return len(p) <= MAX_PROFILE_LENGTH
def __init__(self, conn=None, object_path=None, bus_name=None): """Constructor. Either conn or bus_name is required; object_path is also required. :Parameters: `conn` : dbus.connection.Connection or None The connection on which to export this object. If None, use the Bus associated with the given ``bus_name``. If there is no ``bus_name`` either, the object is not initially available on any Connection. For backwards compatibility, if an instance of dbus.service.BusName is passed as the first parameter, this is equivalent to passing its associated Bus as ``conn``, and passing the BusName itself as ``bus_name``. `object_path` : str or None A D-Bus object path at which to make this Object available immediately. If this is not None, a `conn` or `bus_name` must also be provided. `bus_name` : dbus.service.BusName or None Represents a well-known name claimed by this process. A reference to the BusName object will be held by this Object, preventing the name from being released during this Object's lifetime (unless it's released manually). """ if object_path is not None: validate_object_path(object_path) if isinstance(conn, BusName): # someone's using the old API; don't gratuitously break them bus_name = conn conn = bus_name.get_bus() elif conn is None: if bus_name is not None: # someone's using the old API but naming arguments, probably conn = bus_name.get_bus() #: Either an object path, None or _MANY self._object_path = None #: Either a dbus.connection.Connection, None or _MANY self._connection = None #: A list of tuples (Connection, object path, False) where the False #: is for future expansion (to support fallback paths) self._locations = [] #: Lock protecting `_locations`, `_connection` and `_object_path` self._locations_lock = threading.Lock() #: True if this is a fallback object handling a whole subtree. self._fallback = False self._name = bus_name if conn is None and object_path is not None: raise TypeError('If object_path is given, either conn or bus_name ' 'is required') if conn is not None and object_path is not None: self.add_to_connection(conn, object_path)
def profile_name_valid(p): try: dbus.validate_bus_name("com." + p) dbus.validate_object_path("/" + p) except (TypeError, ValueError): return False return len(p) <= MAX_PROFILE_LENGTH