本文整理汇总了Python中dbus.ObjectPath方法的典型用法代码示例。如果您正苦于以下问题:Python dbus.ObjectPath方法的具体用法?Python dbus.ObjectPath怎么用?Python dbus.ObjectPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dbus
的用法示例。
在下文中一共展示了dbus.ObjectPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_agent_with_defaults
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def test_agent_with_defaults(self, patched_system_bus):
mock_system_bus = mock.MagicMock()
patched_system_bus.return_value = mock_system_bus
mock_system_bus.get_object.return_value = dbus.ObjectPath('/org/bluez')
agent = bt_manager.BTAgent()
obj = dbus.ObjectPath('/org/bluez/985/hci0/dev_00_11_67_D2_AB_EE')
uuid = dbus.String(u'00001108-0000-1000-8000-00805f9b34fb')
pin_code = dbus.String('0000')
pass_key = dbus.UInt32(0)
mode = 'Mode'
self.assertEqual(agent.Release(), None)
self.assertEqual(agent.Authorize(obj, uuid), None)
self.assertEqual(agent.RequestPinCode(obj), pin_code)
self.assertEqual(agent.RequestPasskey(obj), pass_key)
self.assertEqual(agent.DisplayPasskey(obj, pass_key), None)
self.assertEqual(agent.RequestConfirmation(obj, pass_key), None)
self.assertEqual(agent.ConfirmModeChange(mode), None)
self.assertEqual(agent.Cancel(), None)
示例2: test_agent_corner_cases
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def test_agent_corner_cases(self, patched_system_bus):
mock_system_bus = mock.MagicMock()
patched_system_bus.return_value = mock_system_bus
mock_system_bus.get_object.return_value = dbus.ObjectPath('/org/bluez')
agent = bt_manager.BTAgent(default_pin_code=None,
default_pass_key=None)
obj = dbus.ObjectPath('/org/bluez/985/hci0/dev_00_11_67_D2_AB_EE')
try:
exception_raised = False
agent.RequestPinCode(obj)
except bt_manager.BTRejectedException:
exception_raised = True
self.assertTrue(exception_raised)
try:
exception_raised = False
agent.RequestPasskey(obj)
except bt_manager.BTRejectedException:
exception_raised = True
self.assertTrue(exception_raised)
示例3: test_sbc_caps_conversion
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def test_sbc_caps_conversion(self, patched_system_bus):
mock_system_bus = mock.MagicMock()
patched_system_bus.return_value = mock_system_bus
mock_system_bus.get_object.return_value = dbus.ObjectPath('/org/bluez')
media = bt_manager.SBCAudioCodec(uuid='uuid', path='/endpoint/test')
config = bt_manager.SBCCodecConfig(bt_manager.SBCChannelMode.ALL,
bt_manager.SBCSamplingFrequency.ALL,
bt_manager.SBCAllocationMethod.ALL,
bt_manager.SBCSubbands.ALL,
bt_manager.SBCBlocks.ALL,
2,
64)
dbus_config = media._make_config(config)
self.assertEqual(dbus_config, dbus.Array([dbus.Byte(0xFF),
dbus.Byte(0xFF),
dbus.Byte(2),
dbus.Byte(64)]))
self.assertEqual(media._parse_config(dbus_config), config)
示例4: unwrap
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [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: set_videopos
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def set_videopos(self,new_coordinates):
logger.debug('CameraStream: ' + self.name + ' Set new position for ' + self.name + ' with new coordinates: + ' + str(new_coordinates) + ' on dbus interface')
if platform.system() == "Linux":
if self.dbusconnection is not None:
self.dbusconnection.VideoPosWrapper((ObjectPath('/not/used'), String(" ".join(map(str,new_coordinates)))))
else:
logger.error('CameraStream: ' + self.name + ' has no dbus connection, probably because omxplayer crashed because it can not connect to this stream. As a result we could not change its videopos dynamically for this stream at this time.')
示例6: hide_stream
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def hide_stream(self):
logger.debug('CameraStream: Hide stream instruction ' + self.name + ' received from dbus interface')
if platform.system() == "Linux":
if self.dbusconnection is not None:
self.dbusconnection.player_interface.SetAlpha(ObjectPath('/not/used'), Int64(0))
else:
logger.error('CameraStream: ' + self.name + ' has no dbus connection, probably because omxplayer crashed because it can not connect to this stream. As a result we could not hide this stream at this time.')
示例7: unhide_stream
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def unhide_stream(self):
logger.debug('CameraStream: Unhide stream instruction ' + self.name + ' received from dbus interface')
if platform.system() == "Linux":
if self.dbusconnection is not None:
self.dbusconnection.player_interface.SetAlpha(ObjectPath('/not/used'), Int64(255))
else:
logger.error('CameraStream: ' + self.name + ' has no dbus connection, probably because omxplayer crashed because it can not connect to this stream. As a result we could not unhide this stream at this time.')
示例8: _from_dbus_type
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def _from_dbus_type(fn):
def from_dbus_type(dbusVal):
def from_dbus_dict(dbusDict):
d = dict()
for dbusKey, dbusVal in dbusDict.items():
d[from_dbus_type(dbusKey)] = from_dbus_type(dbusVal)
return d
typeUnwrapper = {
dbus.types.Dictionary: from_dbus_dict,
dbus.types.Array: lambda x: list(map(from_dbus_type, x)),
dbus.types.Double: float,
dbus.types.Boolean: bool,
dbus.types.Byte: int,
dbus.types.Int16: int,
dbus.types.Int32: int,
dbus.types.Int64: int,
dbus.types.UInt32: int,
dbus.types.UInt64: int,
dbus.types.ByteArray: str,
dbus.types.ObjectPath: str,
dbus.types.Signature: str,
dbus.types.String: str
}
try:
return typeUnwrapper[type(dbusVal)](dbusVal)
except KeyError:
return dbusVal
def wrapped(fn, self, *args, **kwargs):
return from_dbus_type(fn(self, *args, **kwargs))
return decorator(wrapped, fn)
# CLASSES
示例9: set_position
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def set_position(self, position):
"""
Set the video to playback position to `position` seconds from the start of the video
Args:
position (float): The position in seconds.
"""
self._player_interface.SetPosition(ObjectPath("/not/used"), Int64(position * 1000.0 * 1000))
self.positionEvent(self, position)
示例10: set_alpha
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def set_alpha(self, alpha):
"""
Set the transparency of the video overlay
Args:
alpha (float): The transparency (0..255)
"""
self._player_interface.SetAlpha(ObjectPath('/not/used'), Int64(alpha))
示例11: set_aspect_mode
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def set_aspect_mode(self, mode):
"""
Set the aspect mode of the video
Args:
mode (str): One of ("letterbox" | "fill" | "stretch")
"""
self._player_interface.SetAspectMode(ObjectPath('/not/used'), String(mode))
示例12: set_video_pos
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def set_video_pos(self, x1, y1, x2, y2):
"""
Set the video position on the screen
Args:
x1 (int): Top left x coordinate (px)
y1 (int): Top left y coordinate (px)
x2 (int): Bottom right x coordinate (px)
y2 (int): Bottom right y coordinate (px)
"""
position = "%s %s %s %s" % (str(x1),str(y1),str(x2),str(y2))
self._player_interface.VideoPos(ObjectPath('/not/used'), String(position))
示例13: set_video_crop
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def set_video_crop(self, x1, y1, x2, y2):
"""
Args:
x1 (int): Top left x coordinate (px)
y1 (int): Top left y coordinate (px)
x2 (int): Bottom right x coordinate (px)
y2 (int): Bottom right y coordinate (px)
"""
crop = "%s %s %s %s" % (str(x1),str(y1),str(x2),str(y2))
self._player_interface.SetVideoCropPos(ObjectPath('/not/used'), String(crop))
示例14: setUp
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def setUp(self):
patcher = mock.patch('dbus.Interface', MockDBusInterface)
patcher.start()
self.addCleanup(patcher.stop)
patcher = mock.patch('dbus.SystemBus')
patched_system_bus = patcher.start()
self.addCleanup(patcher.stop)
mock_system_bus = mock.MagicMock()
patched_system_bus.return_value = mock_system_bus
mock_system_bus.get_object.return_value = dbus.ObjectPath('/org/bluez')
self.mock_system_bus = mock_system_bus
示例15: test_adapter_find_device
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ObjectPath [as 别名]
def test_adapter_find_device(self):
adapter = bt_manager.BTAdapter()
dev = adapter.find_device('00:11:67:D2:AB:EE')
self.assertEqual(dev,
dbus.ObjectPath('/org/bluez/985/hci0/dev_00_11_67_D2_AB_EE')) # noqa