Python dbus.PROPERTIES_IFACE Examples

The following are 16 code examples of dbus.PROPERTIES_IFACE(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module dbus , or try the search function .
Example #1
Source File: systemd.py    From ideascube with GNU Affero General Public License v3.0 6 votes vote down vote up
def __init__(self, path):
        proxy = dbus.SystemBus().get_object('org.freedesktop.systemd1', path)
        self._unit = dbus.Interface(
            proxy, dbus_interface='org.freedesktop.systemd1.Unit')

        props = self._unit.GetAll(
            'org.freedesktop.systemd1.Unit',
            dbus_interface=dbus.PROPERTIES_IFACE)

        for prop in props:
            prop = str(prop)

            if not hasattr(self.__class__, prop):
                setattr(self.__class__, prop, self._make_property(prop))

        if self.LoadState == 'not-found':
            raise NoSuchUnit(self.Id) 
Example #2
Source File: GATT.py    From python-bluezero with MIT License 6 votes vote down vote up
def __init__(self, adapter_addr, device_addr, profile_uuid):
        """
        Remote GATT Profile Initialisation.

        :param profile_path: dbus path to the profile.
        """
        self.profile_path = dbus_tools.get_profile_path(adapter_addr,
                                                        device_addr,
                                                        profile_uuid)
        self.bus = dbus.SystemBus()
        self.profile_object = self.bus.get_object(
            constants.BLUEZ_SERVICE_NAME,
            self.profile_path)
        self.profile_methods = dbus.Interface(
            self.profile_object,
            constants.GATT_PROFILE_IFACE)
        self.profile_props = dbus.Interface(self.profile_object,
                                            dbus.PROPERTIES_IFACE) 
Example #3
Source File: GATT.py    From python-bluezero with MIT License 6 votes vote down vote up
def __init__(self, adapter_addr):
        """
        GATT Manager Initialisation.

        :param manager_path: dbus path to the GATT Manager.
        """
        self.manager_path = dbus_tools.get_dbus_path(adapter_addr)
        self.bus = dbus.SystemBus()
        self.manager_obj = self.bus.get_object(
            constants.BLUEZ_SERVICE_NAME,
            self.manager_path)
        self.manager_methods = dbus.Interface(
            self.manager_obj,
            constants.GATT_MANAGER_IFACE)
        self.manager_props = dbus.Interface(self.manager_obj,
                                            dbus.PROPERTIES_IFACE) 
Example #4
Source File: dbus_tools.py    From python-bluezero with MIT License 6 votes vote down vote up
def get_props(adapter=None,
              device=None,
              service=None,
              characteristic=None,
              descriptor=None):
    """
    Get properties for the specified object
    :param adapter: Adapter Address
    :param device:  Device Address
    :param service:  GATT Service UUID
    :param characteristic: GATT Characteristic UUID
    :param descriptor: GATT Descriptor UUID
    :return: Object of the DBus properties available
    """
    path_obj = get_dbus_path(adapter,
                             device,
                             service,
                             characteristic,
                             descriptor)

    return get_dbus_iface(dbus.PROPERTIES_IFACE, get_dbus_obj(path_obj)) 
Example #5
Source File: advertisement.py    From python-bluezero with MIT License 6 votes vote down vote up
def __init__(self, adapter_addr=None):

        self.bus = dbus.SystemBus()

        if adapter_addr is None:
            adapters = adapter.list_adapters()
            if len(adapters) > 0:
                adapter_addr = adapters[0]

        self.advert_mngr_path = dbus_tools.get_dbus_path(adapter=adapter_addr)
        self.advert_mngr_obj = self.bus.get_object(
            constants.BLUEZ_SERVICE_NAME,
            self.advert_mngr_path)
        self.advert_mngr_methods = dbus.Interface(
            self.advert_mngr_obj,
            constants.LE_ADVERTISING_MANAGER_IFACE)
        self.advert_mngr_props = dbus.Interface(self.advert_mngr_obj,
                                                dbus.PROPERTIES_IFACE) 
Example #6
Source File: gatt_linux.py    From gatt-python with MIT License 5 votes vote down vote up
def run(self):
        """
        Starts the main loop that is necessary to receive Bluetooth events from the Bluetooth adapter.

        This call blocks until you call `stop()` to stop the main loop.
        """

        if self._main_loop:
            return

        self._interface_added_signal = self._bus.add_signal_receiver(
            self._interfaces_added,
            dbus_interface='org.freedesktop.DBus.ObjectManager',
            signal_name='InterfacesAdded')

        # TODO: Also listen to 'interfaces removed' events?

        self._properties_changed_signal = self._bus.add_signal_receiver(
            self._properties_changed,
            dbus_interface=dbus.PROPERTIES_IFACE,
            signal_name='PropertiesChanged',
            arg0='org.bluez.Device1',
            path_keyword='path')

        def disconnect_signals():
            for device in self._devices.values():
                device.invalidate()
            self._properties_changed_signal.remove()
            self._interface_added_signal.remove()

        self._main_loop = GObject.MainLoop()
        try:
            self._main_loop.run()
            disconnect_signals()
        except Exception:
            disconnect_signals()
            raise 
Example #7
Source File: systemd.py    From ideascube with GNU Affero General Public License v3.0 5 votes vote down vote up
def _make_property(self, name):
        def get_func(self):
            return dbus_to_python(self._unit.Get(
                'org.freedesktop.systemd1.Unit', name,
                dbus_interface=dbus.PROPERTIES_IFACE))

        return property(get_func) 
Example #8
Source File: dbuswpasupplicant.py    From pywificontrol with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __get_properties(self):
        try:
            obj = self._bus.get_object(self._BASE_NAME, self._BASE_PATH)
            properties_interface = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
            return properties_interface.GetAll(self._BASE_NAME)
        except dbus.exceptions.DBusException as error:
            raise ServiceError(error) 
Example #9
Source File: dbuswpasupplicant.py    From pywificontrol with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __get_property(self, property_name):
        try:
            obj = self._bus.get_object(self._BASE_NAME, self._BASE_PATH)
            properties_interface = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
            return properties_interface.Get(self._BASE_NAME, property_name)
        except dbus.exceptions.DBusException as error:
            raise PropertyError(error) 
Example #10
Source File: dbuswpasupplicant.py    From pywificontrol with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __set_property(self, property_name, property_value):
        try:
            obj = self._bus.get_object(self._BASE_NAME, self._BASE_PATH)
            properties_interface = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
            properties_interface.Set(self._BASE_NAME, property_name, property_value)
        except dbus.exceptions.DBusException as error:
            raise PropertyError(error) 
Example #11
Source File: dbuswpasupplicant.py    From pywificontrol with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __get_property(self, property_name):
        try:
            obj = self._bus.get_object(self._BASE_NAME, self._interface_path)
            properties_interface = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
            return properties_interface.Get(self._INTERFACE_NAME, property_name)
        except dbus.exceptions.DBusException as error:
            raise PropertyError(error) 
Example #12
Source File: dbuswpasupplicant.py    From pywificontrol with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __set_property(self, property_name, property_value):
        try:
            obj = self._bus.get_object(self._BASE_NAME, self._interface_path)
            properties_interface = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
            properties_interface.Set(self._INTERFACE_NAME, property_name, property_value)
        except dbus.exceptions.DBusException as error:
            raise PropertyError(error) 
Example #13
Source File: dbuswpasupplicant.py    From pywificontrol with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __set_property(self, bss_path, property_name, property_value):
        try:
            obj = self._bus.get_object(self._BASE_NAME, bss_path)
            properties_interface = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
            properties_interface.Set(self._BSS_NAME, property_name, property_value)
        except dbus.exceptions.DBusException as error:
            raise PropertyError(error) 
Example #14
Source File: dbuswpasupplicant.py    From pywificontrol with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __get_properties(self, network_path):
        try:
            obj = self._bus.get_object(self._BASE_NAME, network_path)
            properties_interface = dbus.Interface(obj, dbus.PROPERTIES_IFACE)
            return properties_interface.GetAll(self._NETWORK_NAME)
        except dbus.exceptions.DBusException as error:
            raise PropertyError(error) 
Example #15
Source File: device.py    From python-bluezero with MIT License 5 votes vote down vote up
def __init__(self, adapter_addr, device_addr):
        """Default initialiser.

        Creates object for the specified remote Bluetooth device.
        This is on the specified adapter specified.

        :param adapter_addr: Address of the local Bluetooth adapter.
        :param device_addr: Address of the remote Bluetooth device.
        """
        self.bus = dbus.SystemBus()
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        self.mainloop = GObject.MainLoop()

        device_path = dbus_tools.get_dbus_path(adapter_addr, device_addr)
        if not device_path:
            raise ValueError("Cannot find a device: " + device_addr +
                             " using adapter: " + adapter_addr)

        self.remote_device_path = device_path
        self.remote_device_obj = self.bus.get_object(
            constants.BLUEZ_SERVICE_NAME,
            self.remote_device_path)
        self.remote_device_methods = dbus.Interface(
            self.remote_device_obj,
            constants.DEVICE_INTERFACE)
        self.remote_device_props = dbus.Interface(self.remote_device_obj,
                                                  dbus.PROPERTIES_IFACE) 
Example #16
Source File: media_player.py    From python-bluezero with MIT License 5 votes vote down vote up
def __init__(self, device_addr):
        """Default initialiser.

        Creates the interface to the remote Bluetooth device.

        :param device_addr: Address of Bluetooth device player to use.
        """
        self.player_path = _find_player_path(device_addr)
        self.player_object = dbus_tools.get_dbus_obj(self.player_path)
        self.player_methods = dbus_tools.get_dbus_iface(
            constants.MEDIA_PLAYER_IFACE, self.player_object)
        self.player_props = dbus_tools.get_dbus_iface(
            dbus.PROPERTIES_IFACE, self.player_object)