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


Python dbus.UInt16方法代码示例

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


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

示例1: write_value

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt16 [as 别名]
def write_value(self, value, offset=0):
        """
        Attempts to write a value to the characteristic.

        Success or failure will be notified by calls to `write_value_succeeded` or `write_value_failed` respectively.

        :param value: array of bytes to be written
        :param offset: offset from where to start writing the bytes (defaults to 0)
        """
        bytes = [dbus.Byte(b) for b in value]

        try:
            self._object.WriteValue(
                bytes,
                {'offset': dbus.UInt16(offset, variant_level=1)},
                reply_handler=self._write_value_succeeded,
                error_handler=self._write_value_failed,
                dbus_interface='org.bluez.GattCharacteristic1')
        except dbus.exceptions.DBusException as e:
            self._write_value_failed(self, error=e) 
开发者ID:getsenic,项目名称:gatt-python,代码行数:22,代码来源:gatt_linux.py

示例2: unwrap

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt16 [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: unwrap

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt16 [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

示例4: read_value

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt16 [as 别名]
def read_value(self, offset=0):
        """
        Reads the value of this descriptor.

        When successful, the value will be returned, otherwise `descriptor_read_value_failed()` of the related
        device is invoked.
        """
        try:
            val = self._object.ReadValue(
                {'offset': dbus.UInt16(offset, variant_level=1)},
                dbus_interface='org.bluez.GattDescriptor1')
            return val
        except dbus.exceptions.DBusException as e:
            error = _error_from_dbus_error(e)
            self.service.device.descriptor_read_value_failed(self, error=error) 
开发者ID:getsenic,项目名称:gatt-python,代码行数:17,代码来源:gatt_linux.py

示例5: base_to_python

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt16 [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

示例6: convert

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt16 [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 
开发者ID:atareao,项目名称:cpu-g,代码行数:33,代码来源:upower.py

示例7: convert

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt16 [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 
开发者ID:atareao,项目名称:my-weather-indicator,代码行数:34,代码来源:ipaddress.py

示例8: __init__

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt16 [as 别名]
def __init__(self, channel=1):
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        self.bus = dbus.SystemBus()
        self.uuid = "1101"
        self.opts = {
            "Name": "Reach SPP",
            "Channel": dbus.UInt16(channel),
            "AutoConnect": False
        }

        self.manager = dbus.Interface(
            self.bus.get_object("org.bluez", "/org/bluez"),
            "org.bluez.ProfileManager1") 
开发者ID:emlid,项目名称:bluetool,代码行数:15,代码来源:blueserver.py

示例9: base_to_python

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt16 [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 
开发者ID:eduvpn,项目名称:python-eduvpn-client,代码行数:34,代码来源:other_nm.py


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