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


Python方法dbus.Int32代码示例

以下是Python方法dbus.Int32的代码示例。如果您正苦于以下问题:Python dbus.Int32方法的具体用法?Python dbus.Int32怎么用?Python dbus.Int32使用的例子?那么恭喜您, 这里整理的方法代码示例例程将为您提供帮助。您也可以进一步了解该方法所在模块dbus的用法示例。

本文一共展示了dbus.Int32的11个开源代码实例,这些例子默认根据受欢迎程度排序。您可以为喜欢的代码打CALL点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: unwrap

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int32 [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,完整代码来源:networkmanayer.py


示例2: control

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int32 [as 别名]
def control(self,char):

        val = OMXDriver.KEY_MAP[char]
        #logger.info('>control received and sent to omxplayer ' + str(self.pid))
        if self.is_running():
            try:
                self.__iface_player.Action(dbus.Int32(val))
            except dbus.exceptions.DBusException as ex:
                #logger.info('Failed to send control - dbus exception: {}'.format(ex.get_dbus_message()))
                return
        else:
            logger.info('Failed to send control - process not running')
            return

        
    # USE ONLY at end and after load
    # return succces of the operation, several tries if pause did not work and no error reported. 
开发者ID:langolierz,项目:r_e_c_u_r,完整代码来源:old-omxdriver.py


示例3: result

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int32 [as 别名]
def result(operation_id, code, text):
    """Encode a result
    
    This method encodes operation id, result code and result text into
    a dictionary of dbus types.
    
    @param operation_id Id of the operation for which the result is reported
    @param code Result code of the operation (one of SWMResult)
    @param text Text message
    
    @return Result dictionary using dbus types.
    """
    if not SWMResult.isValid(code):
        code = SWMResult.SWM_GENERAL_ERROR
    
    return {
        'id': dbus.String(operation_id, variant_level=1),
        'result_code': dbus.Int32(code, variant_level=1),
        'result_text': dbus.String(text, variant_level=1)
    } 
开发者ID:GENIVI,项目:genivi_swm,完整代码来源:swm.py


示例4: convert

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int32 [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,完整代码来源:ipaddress.py


示例5: convert

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int32 [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)
    else:
        return dbus_obj 
开发者ID:atareao,项目:cpu-g,完整代码来源:upower.py


示例6: base_to_python

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int32 [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,完整代码来源:other_nm.py


示例7: test_dbus_wrap_int

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int32 [as 别名]
def test_dbus_wrap_int(self):
		value = 1121
		dbus_value = dbus_mqtt.wrap_dbus_value(value)
		self.assertIsInstance(dbus_value, dbus.Int32)
		self.assertEqual(dbus.Int32(value, variant_level=1), dbus_value) 
开发者ID:victronenergy,项目:dbus-mqtt,完整代码来源:dbus_mqtt_test.py


示例8: test_dbus_wrap_array

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int32 [as 别名]
def test_dbus_wrap_array(self):
		value = [1]
		dbus_value = dbus_mqtt.wrap_dbus_value(value)
		self.assertIsInstance(dbus_value, dbus.Array)
		self.assertEqual(dbus.Array([dbus.Int32(1, variant_level=1)]), dbus_value) 
开发者ID:victronenergy,项目:dbus-mqtt,完整代码来源:dbus_mqtt_test.py


示例9: test_dbus_wrap_dict

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int32 [as 别名]
def test_dbus_wrap_dict(self):
		value = {'a' : 3, 'b': 7.0}
		dbus_value = dbus_mqtt.wrap_dbus_value(value)
		print(dbus_value)
		self.assertIsInstance(dbus_value, dbus.Dictionary)
		self.assertEqual(dbus.Dictionary({
			dbus.String('a', variant_level=1): dbus.Int32(3, variant_level=1),
			dbus.String('b', variant_level=1): dbus.Double(7.0, variant_level=1)}, variant_level=1),
			dbus_value) 
开发者ID:victronenergy,项目:dbus-mqtt,完整代码来源:dbus_mqtt_test.py


示例10: test_dbus_unwrap_int32

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int32 [as 别名]
def test_dbus_unwrap_int32(self):
		dbus_value = dbus.Int32(123, variant_level=1)
		value = dbus_mqtt.unwrap_dbus_value(dbus_value)
		self.assertIsInstance(value, int)
		self.assertEqual(int(dbus_value), value) 
开发者ID:victronenergy,项目:dbus-mqtt,完整代码来源:dbus_mqtt_test.py


示例11: set_scan_interval

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import Int32 [as 别名]
def set_scan_interval(self, value):
        return self.__set_property("ScanInterval", dbus.Int32(value)) 
开发者ID:emlid,项目:pywificontrol,完整代码来源:dbuswpasupplicant.py



注:本文示例均筛选自Github等开源项目,代码版权请参考对应项目的License;未经允许,请勿转载。