本文整理汇总了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
示例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))
示例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)
示例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)
示例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
示例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
示例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)
示例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')
示例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()
示例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))
示例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
示例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))
示例13: mask_to_dbus
# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import UInt32 [as 别名]
def mask_to_dbus(mask):
return dbus.UInt32(mask)
示例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)
示例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)