本文整理汇总了Python中dbus.Int64方法的典型用法代码示例。如果您正苦于以下问题:Python dbus.Int64方法的具体用法?Python dbus.Int64怎么用?Python dbus.Int64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dbus
的用法示例。
在下文中一共展示了dbus.Int64方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unwrap
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [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
示例2: unwrap
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [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
示例3: hide_stream
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [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.')
示例4: unhide_stream
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [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.')
示例5: _from_dbus_type
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [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
示例6: seek
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [as 别名]
def seek(self, relative_position):
"""
Seek the video by `relative_position` seconds
Args:
relative_position (float): The position in seconds to seek to.
"""
self._player_interface.Seek(Int64(1000.0 * 1000 * relative_position))
self.seekEvent(self, relative_position)
示例7: set_position
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [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)
示例8: set_layer
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [as 别名]
def set_layer(self, layer):
"""
Set the layer of the Video (default 0). Higher layers are above lower layers
Args:
layer (int): The Layer to switch to.
"""
self._player_interface.SetLayer(Int64(layer))
示例9: set_alpha
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [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))
示例10: base_to_python
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [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
示例11: to_dbus_position
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [as 别名]
def to_dbus_position(p):
return dbus.Int64(p * 1000 * 1000)
示例12: __init__
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [as 别名]
def __init__(self, app, bus):
super().__init__(bus, ObjectPath)
self._app = app
self._metadata = dbus.Dictionary({}, signature='sv', variant_level=1)
self._old_position = dbus.Int64(0)
示例13: _update_song_props
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [as 别名]
def _update_song_props(self, song):
artist = [', '.join((e.name for e in song.artists))] or ['Unknown']
self._metadata.update(dbus.Dictionary({
# make xesam:artist a one-element list to compat with KDE
# KDE will not update artist field if the length>=2
'xesam:artist': artist,
'xesam:url': song.url,
'mpris:length': dbus.Int64(song.duration*1000),
'mpris:trackid': to_track_id(song),
'mpris:artUrl': song.album.cover if song.album else '',
'xesam:album': song.album_name,
'xesam:title': song.title,
}, signature='sv'))
changed_properties = dbus.Dictionary({'Metadata': self._metadata})
self.PropertiesChanged(PlayerInterface, changed_properties, [])
示例14: convert
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [as 别名]
def convert(dbus_obj):
"""Converts dbus_obj from dbus type to python type.
:param dbus_obj: dbus object.
:returns: dbus_obj in python type.
"""
_isinstance = partial(isinstance, dbus_obj)
ConvertType = namedtuple('ConvertType', 'pytype dbustypes')
pyint = ConvertType(int, (dbus.Byte, dbus.Int16, dbus.Int32, dbus.Int64,
dbus.UInt16, dbus.UInt32, dbus.UInt64))
pybool = ConvertType(bool, (dbus.Boolean, ))
pyfloat = ConvertType(float, (dbus.Double, ))
pylist = ConvertType(lambda _obj: list(map(convert, dbus_obj)),
(dbus.Array, ))
pytuple = ConvertType(lambda _obj: tuple(map(convert, dbus_obj)),
(dbus.Struct, ))
types_str = (dbus.ObjectPath, dbus.Signature, dbus.String)
pystr = ConvertType(str, types_str)
pydict = ConvertType(
lambda _obj: dict(zip(map(convert, dbus_obj.keys()),
map(convert, dbus_obj.values())
)
),
(dbus.Dictionary, )
)
for conv in (pyint, pybool, pyfloat, pylist, pytuple, pystr, pydict):
if any(map(_isinstance, conv.dbustypes)):
return conv.pytype(dbus_obj)
return dbus_obj
示例15: convert
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int64 [as 别名]
def convert(dbus_obj):
"""Converts dbus_obj from dbus type to python type.
:param dbus_obj: dbus object.
:returns: dbus_obj in python type.
"""
_isinstance = partial(isinstance, dbus_obj)
ConvertType = namedtuple('ConvertType', 'pytype dbustypes')
pyint = ConvertType(int, (dbus.Byte, dbus.Int16, dbus.Int32, dbus.Int64,
dbus.UInt16, dbus.UInt32, dbus.UInt64))
pybool = ConvertType(bool, (dbus.Boolean, ))
pyfloat = ConvertType(float, (dbus.Double, ))
pylist = ConvertType(lambda _obj: list(map(convert, dbus_obj)),
(dbus.Array, ))
pytuple = ConvertType(lambda _obj: tuple(map(convert, dbus_obj)),
(dbus.Struct, ))
types_str = (dbus.ObjectPath, dbus.Signature, dbus.String)
pystr = ConvertType(str, types_str)
pydict = ConvertType(
lambda _obj: dict(list(zip(list(map(convert, dbus_obj.keys())),
list(map(convert, dbus_obj.values()))
))
),
(dbus.Dictionary, )
)
for conv in (pyint, pybool, pyfloat, pylist, pytuple, pystr, pydict):
if any(map(_isinstance, conv.dbustypes)):
return conv.pytype(dbus_obj)
else:
return dbus_obj