本文整理汇总了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))
示例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
示例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()
示例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
示例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
示例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))
示例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))
示例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))
示例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)
示例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)
示例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))
示例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))
示例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
示例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))
示例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}