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


Python dbus.UInt32方法代码示例

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


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

示例1: auth_with_policykit

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt32 [as 别名]
def auth_with_policykit(action,
                        bus_name,
                        object_path,
                        interface_name,
                        interactive=1, ):
    system_bus = dbus.SystemBus()
    obj = system_bus.get_object(bus_name, object_path, interface_name)

    policykit = dbus.Interface(obj, interface_name)
    pid = os.getpid()

    subject = ('unix-process', {'pid': dbus.UInt32(pid,
                                                   variant_level=1),
                                'start-time': dbus.UInt64(0), })
    details = {'': ''}
    flags = dbus.UInt32(interactive)
    cancel_id = ''
    (ok, notused, details) = policykit.CheckAuthorization(
        subject, action, details, flags, cancel_id)

    return ok 
开发者ID:dragondjf,项目名称:QMusic,代码行数:23,代码来源:ipc.py

示例2: test_all

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt32 [as 别名]
def test_all(self):

        val = [1, 2, 3, 4, 5]
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Array, val),  # noqa
                         dbus.Array(val))
        val = -1
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Int32, val),  # noqa
                         dbus.Int32(val))
        val = 1
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.UInt32, val),  # noqa
                         dbus.UInt32(val))
        val = 'Test'
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.String, val),  # noqa
                         dbus.String(val))
        val = {'Hello': 1}
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Dictionary,  # noqa
                                                           val),
                         dbus.Dictionary(val))
        val = 'True'
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Boolean, val),  # noqa
                         dbus.Boolean(True))
        val = 'False'
        self.assertEqual(bt_manager.interface.translate_to_dbus_type(dbus.Boolean, val),  # noqa
                         dbus.Boolean(False)) 
开发者ID:liamw9534,项目名称:bt-manager,代码行数:26,代码来源:test_bt_bus.py

示例3: test_agent_with_defaults

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt32 [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) 
开发者ID:liamw9534,项目名称:bt-manager,代码行数:22,代码来源:test_bt_bus.py

示例4: _check_permission

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt32 [as 别名]
def _check_permission(self, sender, action):
        '''
        Verifies if the specified action is permitted, and raises
        an AccessDeniedException if not.

        The caller should use ObtainAuthorization() to get permission.
        '''

        try:
            if sender:
                kit = dbus.SystemBus().get_object('org.freedesktop.PolicyKit1', '/org/freedesktop/PolicyKit1/Authority')
                kit = dbus.Interface(kit, 'org.freedesktop.PolicyKit1.Authority')

                (granted, _, details) = kit.CheckAuthorization(
                                ('system-bus-name', {'name': sender}),
                                action, {}, dbus.UInt32(1), '', timeout=600)

                if not granted:
                    raise AccessDeniedException('Session not authorized by PolicyKit')

        except AccessDeniedException:
            raise

        except dbus.DBusException as ex:
            raise AccessDeniedException(ex.message) 
开发者ID:gerardpuig,项目名称:ubuntu-cleaner,代码行数:27,代码来源:__init__.py

示例5: unwrap

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

示例6: unwrap

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

示例7: RequestPasskey

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt32 [as 别名]
def RequestPasskey(self, device):
        logger.info("RequestPasskey: {}\n".format(device))

        if not self._trust(device):
            logger.error("RequestPasskey: failed to trust\n")
            raise _Rejected

        dev_info = self._get_device_info(device)

        try:
            passkey = int(self._client.request_passkey(dev_info))
        except BaseException as error:
            logger.error("RequestPasskey: {}\n".format(error))
            raise _Rejected

        return dbus.UInt32(passkey) 
开发者ID:emlid,项目名称:bluetool,代码行数:18,代码来源:agent.py

示例8: agent_event_request_pass_key

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt32 [as 别名]
def agent_event_request_pass_key(event, device):
    print '\n========================================================='
    print 'Agent event:', event
    print 'Device:', device
    print 'Using pass code 1234765'
    return dbus.UInt32('1234765') 
开发者ID:liamw9534,项目名称:bt-manager,代码行数:8,代码来源:demo.py

示例9: publish

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt32 [as 别名]
def publish(self, cname):
        """ Push the cname into the avahi stack
            copied from https://gist.github.com/gdamjan/3168336
        """
        bus = dbus.SystemBus()
        server = dbus.Interface(
            bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER),
            avahi.DBUS_INTERFACE_SERVER
        )
        group = dbus.Interface(
            bus.get_object(avahi.DBUS_NAME, server.EntryGroupNew()),
            avahi.DBUS_INTERFACE_ENTRY_GROUP
        )

        cname = self.encode(cname)
        rdata = self.encode_rdata(server.GetHostNameFqdn())
        rdata = avahi.string_to_byte_array(rdata)

        group.AddRecord(
            avahi.IF_UNSPEC,
            avahi.PROTO_UNSPEC,
            dbus.UInt32(0),
            cname,
            Settings.CLASS_IN,
            Settings.TYPE_CNAME,
            Settings.TTL,
            rdata
        )
        group.Commit() 
开发者ID:theonion,项目名称:ansible-roles,代码行数:31,代码来源:avahi-aliases.py

示例10: set_ap_scan

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt32 [as 别名]
def set_ap_scan(self, value):
        return self.__set_property("ApScan", dbus.UInt32(value)) 
开发者ID:emlid,项目名称:pywificontrol,代码行数:4,代码来源:dbuswpasupplicant.py

示例11: base_to_python

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

示例12: addr_to_dbus

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt32 [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)) 
开发者ID:AstroPrint,项目名称:AstroBox,代码行数:7,代码来源:NetworkManager.py

示例13: mask_to_dbus

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt32 [as 别名]
def mask_to_dbus(mask):
				return dbus.UInt32(mask) 
开发者ID:AstroPrint,项目名称:AstroBox,代码行数:4,代码来源:NetworkManager.py

示例14: RequestPasskey

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt32 [as 别名]
def RequestPasskey(self, device):
        print("RequestPasskey (%s)" % (device))
        set_trusted(device)
        passkey = "000000"
        return dbus.UInt32(passkey) 
开发者ID:clockworkpi,项目名称:launcher,代码行数:7,代码来源:agent.py

示例15: RequestPasskey

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt32 [as 别名]
def RequestPasskey(self, device):
        print("RequestPasskey (%s)" % (device))
        set_trusted(device)
        passkey = ask("Enter passkey: ")
        return dbus.UInt32(passkey) 
开发者ID:ElevenPaths,项目名称:HomePWN,代码行数:7,代码来源:dirtyagent.py


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