本文整理汇总了Python中dbus.ByteArray方法的典型用法代码示例。如果您正苦于以下问题:Python dbus.ByteArray方法的具体用法?Python dbus.ByteArray怎么用?Python dbus.ByteArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dbus
的用法示例。
在下文中一共展示了dbus.ByteArray方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unwrap
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ByteArray [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 ByteArray [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: set_icon_from_pixbuf
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ByteArray [as 别名]
def set_icon_from_pixbuf(self, icon):
"""Set a custom icon from a GdkPixbuf.
"""
struct = (
icon.get_width(),
icon.get_height(),
icon.get_rowstride(),
icon.get_has_alpha(),
icon.get_bits_per_sample(),
icon.get_n_channels(),
dbus.ByteArray(icon.get_pixels())
)
self.hints['icon_data'] = struct
示例4: base_to_python
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ByteArray [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
示例5: addr_to_dbus
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ByteArray [as 别名]
def addr_to_dbus(addr,family):
if (family == socket.AF_INET):
return dbus.UInt32(struct.unpack('I', socket.inet_pton(family,addr))[0])
else:
return dbus.ByteArray(socket.inet_pton(family,addr))
示例6: wrap
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ByteArray [as 别名]
def wrap(self, val):
if isinstance(val, NMDbusInterface):
return val.object_path
if hasattr(val, 'mro'):
for klass in val.mro():
if klass.__module__ == '_dbus_bindings':
return val
if hasattr(val, '__iter__') and not isinstance(val, basestring):
if hasattr(val, 'items'):
return dict([(x, self.wrap(y)) for x, y in val.items()])
else:
if (isinstance(val, dbus.Struct) or isinstance(val, dbus.ByteArray)):
return val
return [self.wrap(x) for x in val]
return val
示例7: addr_to_dbus
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ByteArray [as 别名]
def addr_to_dbus(addr, family):
if (family == socket.AF_INET):
return dbus.UInt32(struct.unpack('I', socket.inet_pton(family, addr))[0])
else:
return dbus.ByteArray(socket.inet_pton(family, addr))
示例8: base_to_python
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ByteArray [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)
try:
return globals()[classname](val)
except ObjectVanished:
return None
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
示例9: addr_to_dbus
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import ByteArray [as 别名]
def addr_to_dbus(addr, family):
if family == socket.AF_INET:
return dbus.UInt32(struct.unpack('I', socket.inet_pton(family, addr))[0])
else:
return dbus.ByteArray(socket.inet_pton(family, addr))