当前位置: 首页>>代码示例>>Python>>正文


Python dbus.Boolean方法代码示例

本文整理汇总了Python中dbus.Boolean方法的典型用法代码示例。如果您正苦于以下问题:Python dbus.Boolean方法的具体用法?Python dbus.Boolean怎么用?Python dbus.Boolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dbus的用法示例。


在下文中一共展示了dbus.Boolean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_all

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def test_all(self):

        val = [1, 2, 3, 4, 5]
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Array, val),  # noqa
                         dbus.Array(val))
        val = -1
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Int32, val),  # noqa
                         dbus.Int32(val))
        val = 1
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.UInt32, val),  # noqa
                         dbus.UInt32(val))
        val = 'Test'
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.String, val),  # noqa
                         dbus.String(val))
        val = {'Hello': 1}
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Dictionary,  # noqa
                                                           val),
                         dbus.Dictionary(val))
        val = 'True'
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Boolean, val),  # noqa
                         dbus.Boolean(True))
        val = 'False'
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Boolean, val),  # noqa
                         dbus.Boolean(False)) 
开发者ID:liamw9534,项目名称:bt-manager,代码行数:26,代码来源:test_bt_bus.py

示例2: unwrap

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def unwrap(val):
    if isinstance(val, dbus.ByteArray):
        return "".join([str(x) for x in val])
    if isinstance(val, (dbus.Array, list, tuple)):
        return [unwrap(x) for x in val]
    if isinstance(val, (dbus.Dictionary, dict)):
        return dict([(unwrap(x), unwrap(y)) for x, y in val.items()])
    if isinstance(val, (dbus.Signature, dbus.String)):
        return str(val)
    if isinstance(val, dbus.Boolean):
        return bool(val)
    if isinstance(val, (dbus.Int16, dbus.UInt16, dbus.Int32, dbus.UInt32, dbus.Int64, dbus.UInt64)):
        return int(val)
    if isinstance(val, dbus.Byte):
        return bytes([int(val)])
    return val 
开发者ID:dietervanhoof,项目名称:polybar-spotify-controls,代码行数:18,代码来源:py_spotify_listener.py

示例3: signal_callback

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def signal_callback(self, active):
        """
        Called by DBus when a signal is found

        :param active: If the screensaver is active
        :type active: dbus.Boolean
        """
        active = bool(active)

        if self.monitoring:
            if active:
                # Only trigger once per state change
                if self._active is None or not self._active:
                    self._active = active
                    self.suspend()
            else:
                if self._active is None or self._active:
                    self._active = active
                    self.resume() 
开发者ID:openrazer,项目名称:openrazer,代码行数:21,代码来源:screensaver_monitor.py

示例4: unwrap

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def unwrap(self, val):
        if isinstance(val, dbus.ByteArray):
            return "".join([str(x) for x in val])
        if isinstance(val, (dbus.Array, list, tuple)):
            return [self.unwrap(x) for x in val]
        if isinstance(val, (dbus.Dictionary, dict)):
            return dict([(self.unwrap(x), self.unwrap(y)) for x, y in val.items()])
        if isinstance(val, dbus.ObjectPath):
            if val.startswith('/org/freedesktop/NetworkManager/'):
                classname = val.split('/')[4]
                classname = {
                    'Settings': 'Connection',
                    'Devices': 'Device',
                }.get(classname, classname)
                return globals()[classname](val)
        if isinstance(val, (dbus.Signature, dbus.String)):
            return unicode(val)
        if isinstance(val, dbus.Boolean):
            return bool(val)
        if isinstance(val, (dbus.Int16, dbus.UInt16, dbus.Int32, dbus.UInt32, dbus.Int64, dbus.UInt64)):
            return int(val)
        if isinstance(val, dbus.Byte):
            return bytes([int(val)])
        return val 
开发者ID:atareao,项目名称:my-weather-indicator,代码行数:26,代码来源:networkmanayer.py

示例5: trust

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def trust(self, address):
        try:
            device = bluezutils.find_device(address)
        except (bluezutils.BluezUtilError,
                dbus.exceptions.DBusException) as error:
            logger.error(str(error) + "\n")
            return False

        try:
            props = dbus.Interface(
                self._bus.get_object("org.bluez", device.object_path),
                "org.freedesktop.DBus.Properties")

            if not props.Get("org.bluez.Device1", "Trusted"):
                props.Set("org.bluez.Device1", "Trusted", dbus.Boolean(1))
        except dbus.exceptions.DBusException as error:
            logger.error(str(error) + "\n")
            return False

        return True 
开发者ID:emlid,项目名称:bluetool,代码行数:22,代码来源:bluetool.py

示例6: is_adapter_powered

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def is_adapter_powered(self, powered):
        return self._adapter_properties.Set('org.bluez.Adapter1', 'Powered', dbus.Boolean(powered)) 
开发者ID:getsenic,项目名称:gatt-python,代码行数:4,代码来源:gatt_linux.py

示例7: powerSet

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def powerSet(self, status):
        print("Turning on adapter " + self.path)
        self.prop.Set("org.bluez.Adapter1", "Powered", dbus.Boolean(status)) 
开发者ID:gmsoft-tuxicoman,项目名称:bt-audio,代码行数:5,代码来源:bt-audio.py

示例8: discoverableSet

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def discoverableSet(self, status):
        print("Making adapter " + self.path + " discoverable")
        self.prop.Set("org.bluez.Adapter1", "Discoverable", dbus.Boolean(status)) 
开发者ID:gmsoft-tuxicoman,项目名称:bt-audio,代码行数:5,代码来源:bt-audio.py

示例9: StartDiscovery

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def StartDiscovery(self):
        self._props[dbus.String(u'Discovering')] = \
            dbus.Boolean(True, variant_level=1) 
开发者ID:liamw9534,项目名称:bt-manager,代码行数:5,代码来源:test_bt_bus.py

示例10: StopDiscovery

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def StopDiscovery(self):
        self._props[dbus.String(u'Discovering')] = \
            dbus.Boolean(False, variant_level=1) 
开发者ID:liamw9534,项目名称:bt-manager,代码行数:5,代码来源:test_bt_bus.py

示例11: set_debug_level

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def set_debug_level(self, parameter):
        self.__set_property(dbus.String("DebugTimestamp"), dbus.Boolean(parameter)) 
开发者ID:emlid,项目名称:pywificontrol,代码行数:4,代码来源:dbuswpasupplicant.py

示例12: set_debug_show_keys

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def set_debug_show_keys(self, parameter):
        self.__set_property(dbus.String("DebugShowKeys"), dbus.Boolean(parameter)) 
开发者ID:emlid,项目名称:pywificontrol,代码行数:4,代码来源:dbuswpasupplicant.py

示例13: base_to_python

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def base_to_python(val):
				if isinstance(val, dbus.ByteArray):
						return "".join([str(x) for x in val])
				if isinstance(val, (dbus.Array, list, tuple)):
						return [fixups.base_to_python(x) for x in val]
				if isinstance(val, (dbus.Dictionary, dict)):
						return dict([(fixups.base_to_python(x), fixups.base_to_python(y)) for x,y in val.items()])
				if isinstance(val, dbus.ObjectPath):
						for obj in (NetworkManager, Settings, AgentManager):
								if val == obj.object_path:
										return obj
						if val.startswith('/org/freedesktop/NetworkManager/'):
								classname = val.split('/')[4]
								classname = {
									 'Settings': 'Connection',
									 'Devices': 'Device',
								}.get(classname, classname)
								return globals()[classname](val)
						if val == '/':
								return None
				if isinstance(val, (dbus.Signature, dbus.String)):
						return six.text_type(val)
				if isinstance(val, dbus.Boolean):
						return bool(val)
				if isinstance(val, (dbus.Int16, dbus.UInt16, dbus.Int32, dbus.UInt32, dbus.Int64, dbus.UInt64)):
						return int(val)
				if isinstance(val, dbus.Byte):
						return six.int2byte(int(val))
				return val 
开发者ID:AstroPrint,项目名称:AstroBox,代码行数:31,代码来源:NetworkManager.py

示例14: power_adapter

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def power_adapter(self):
        adapter = self.get_adapter()

        adapter_props = dbus.Interface(bus.get_object(BLUEZ_SERVICE_NAME, adapter),
                "org.freedesktop.DBus.Properties");
        adapter_props.Set("org.bluez.Adapter1", "Powered", dbus.Boolean(1)) 
开发者ID:Douglas6,项目名称:cputemp,代码行数:8,代码来源:bletools.py

示例15: get_properties

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Boolean [as 别名]
def get_properties(self):
        properties = dict()
        properties["Type"] = self.ad_type

        if self.local_name is not None:
            properties["LocalName"] = dbus.String(self.local_name)

        if self.service_uuids is not None:
            properties["ServiceUUIDs"] = dbus.Array(self.service_uuids,
                                                    signature='s')
        if self.solicit_uuids is not None:
            properties["SolicitUUIDs"] = dbus.Array(self.solicit_uuids,
                                                    signature='s')
        if self.manufacturer_data is not None:
            properties["ManufacturerData"] = dbus.Dictionary(
                self.manufacturer_data, signature='qv')

        if self.service_data is not None:
            properties["ServiceData"] = dbus.Dictionary(self.service_data,
                                                        signature='sv')
        if self.include_tx_power is not None:
            properties["IncludeTxPower"] = dbus.Boolean(self.include_tx_power)

        if self.local_name is not None:
            properties["LocalName"] = dbus.String(self.local_name)

        return {LE_ADVERTISEMENT_IFACE: properties} 
开发者ID:Douglas6,项目名称:cputemp,代码行数:29,代码来源:advertisement.py


注:本文中的dbus.Boolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。