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


Python dbus.SystemBus方法代码示例

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


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

示例1: __init__

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import SystemBus [as 别名]
def __init__(self, adapter_name):
        self.listener = None
        self.adapter_name = adapter_name

        self._bus = dbus.SystemBus()
        try:
            adapter_object = self._bus.get_object('org.bluez', '/org/bluez/' + adapter_name)
        except dbus.exceptions.DBusException as e:
            raise _error_from_dbus_error(e)
        object_manager_object = self._bus.get_object("org.bluez", "/")
        self._adapter = dbus.Interface(adapter_object, 'org.bluez.Adapter1')
        self._adapter_properties = dbus.Interface(self._adapter, 'org.freedesktop.DBus.Properties')
        self._object_manager = dbus.Interface(object_manager_object, "org.freedesktop.DBus.ObjectManager")
        self._device_path_regex = re.compile('^/org/bluez/' + adapter_name + '/dev((_[A-Z0-9]{2}){6})$')
        self._devices = {}
        self._discovered_devices = {}
        self._interface_added_signal = None
        self._properties_changed_signal = None
        self._main_loop = None

        self.update_devices() 
开发者ID:getsenic,项目名称:gatt-python,代码行数:23,代码来源:gatt_linux.py

示例2: __init__

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import SystemBus [as 别名]
def __init__(self):
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        setproctitle.setproctitle('pulseaudio-daemon')
        self.mainloop = GObject.MainLoop()
        self.processes = []
        self.check_id = None
        self.is_checking = False

        self._check_processes()

        signals = (
            ('NameOwnerChanged', 'org.freedesktop.DBus.{}',
                self.on_name_owner_changed),
        )
        self.bus = dbus.SystemBus()
        self.core = self.bus.get_object('org.freedesktop.DBus', '/')
        for sig_name, interface, sig_handler in signals:
            self.bus.add_signal_receiver(sig_handler, sig_name) 
开发者ID:masmu,项目名称:pulseaudio-dlna,代码行数:20,代码来源:daemon.py

示例3: __init__

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import SystemBus [as 别名]
def __init__(self, path):
        proxy = dbus.SystemBus().get_object('org.freedesktop.systemd1', path)
        self._unit = dbus.Interface(
            proxy, dbus_interface='org.freedesktop.systemd1.Unit')

        props = self._unit.GetAll(
            'org.freedesktop.systemd1.Unit',
            dbus_interface=dbus.PROPERTIES_IFACE)

        for prop in props:
            prop = str(prop)

            if not hasattr(self.__class__, prop):
                setattr(self.__class__, prop, self._make_property(prop))

        if self.LoadState == 'not-found':
            raise NoSuchUnit(self.Id) 
开发者ID:ideascube,项目名称:ideascube,代码行数:19,代码来源:systemd.py

示例4: is_service_running

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import SystemBus [as 别名]
def is_service_running(service):
    """ Queries systemd through dbus to see if the service is running """
    service_running = False
    bus = SystemBus()
    systemd = bus.get_object('org.freedesktop.systemd1', '/org/freedesktop/systemd1')
    manager = Interface(systemd, dbus_interface='org.freedesktop.systemd1.Manager')
    try:
        service_unit = service if service.endswith('.service') else manager.GetUnit('{0}.service'.format(service))
        service_proxy = bus.get_object('org.freedesktop.systemd1', str(service_unit))
        service_properties = Interface(service_proxy, dbus_interface='org.freedesktop.DBus.Properties')
        service_load_state = service_properties.Get('org.freedesktop.systemd1.Unit', 'LoadState')
        service_active_state = service_properties.Get('org.freedesktop.systemd1.Unit', 'ActiveState')
        if service_load_state == 'loaded' and service_active_state == 'active':
            service_running = True
    except DBusException:
        pass

    return service_running 
开发者ID:openshift,项目名称:origin-ci-tool,代码行数:20,代码来源:openshift_facts.py

示例5: __init__

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

        self.bus = dbus.SystemBus()
        self.adapters = {}


        self.bus.add_signal_receiver(self._interfaceAdded, dbus_interface='org.freedesktop.DBus.ObjectManager', signal_name = "InterfacesAdded")
        self.bus.add_signal_receiver(self._interfaceRemoved, dbus_interface='org.freedesktop.DBus.ObjectManager', signal_name = "InterfacesRemoved")
        self.bus.add_signal_receiver(self._propertiesChanged, dbus_interface='org.freedesktop.DBus.Properties', signal_name = "PropertiesChanged", path_keyword = "path")

        # Find the adapters and create the objects
        obj_mgr = dbus.Interface(self.bus.get_object("org.bluez", "/"), 'org.freedesktop.DBus.ObjectManager')
        objs = obj_mgr.GetManagedObjects()
        for obj_path in objs:
            obj = objs[obj_path]
            if 'org.bluez.Adapter1' in obj:
                adapt_name = obj_path.split('/')[3]
                self.adapters[adapt_name] = Adapter(self.bus, obj_path)
                self.adapters[adapt_name].agentRegister() 
开发者ID:gmsoft-tuxicoman,项目名称:bt-audio,代码行数:21,代码来源:bt-audio.py

示例6: auth_with_policykit

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

示例7: find_device_in_objects

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import SystemBus [as 别名]
def find_device_in_objects(objects, device_address, adapter_pattern=None):
	bus = dbus.SystemBus()
	path_prefix = ""
	if adapter_pattern:
		adapter = find_adapter_in_objects(objects, adapter_pattern)
		path_prefix = adapter.object_path
	for path, ifaces in objects.iteritems():
		device = ifaces.get(DEVICE_INTERFACE)
		if device is None:
			continue
		if (device["Address"] == device_address and
						path.startswith(path_prefix)):
			obj = bus.get_object(SERVICE_NAME, path)
			return dbus.Interface(obj, DEVICE_INTERFACE)

	raise Exception("Bluetooth device not found") 
开发者ID:ElevenPaths,项目名称:DirtyTooth-RaspberryPi,代码行数:18,代码来源:bluezutils.py

示例8: __new__

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import SystemBus [as 别名]
def __new__(klass, object_path=None):
				# If we didn't introspect this one at definition time, let's do it now.
				if object_path and not klass.introspection_data:
						proxy = dbus.SystemBus().get_object(klass.dbus_service, object_path)
						klass.introspection_data = proxy.Introspect(dbus_interface='org.freedesktop.DBus.Introspectable')
						root = etree.fromstring(klass.introspection_data)
						for element in root:
								if element.tag == 'interface' and element.attrib['name'] in klass.interface_names:
										for item in element:
												if item.tag == 'property':
														setattr(klass, item.attrib['name'], type(klass).make_property(klass.__name__, element.attrib['name'], item.attrib))
														klass.properties.append(item.attrib['name'])
												elif item.tag == 'method':
														aname = item.attrib['name']
														if hasattr(klass, aname):
																aname = '_' + aname
														setattr(klass, aname, type(klass).make_method(klass.__name__, element.attrib['name'], item.attrib, list(item)))
												elif item.tag == 'signal':
														SignalDispatcher.args[(element.attrib['name'], item.attrib['name'])] = [(arg.attrib.get('name',None), arg.attrib['type']) for arg in item]
														setattr(klass, 'On' + item.attrib['name'], type(klass).make_signal(klass.__name__, element.attrib['name'], item.attrib))
														klass.signals.append(item.attrib['name'])

				SignalDispatcher.listen_for_restarts()
				return super(NMDbusInterface, klass).__new__(klass) 
开发者ID:AstroPrint,项目名称:AstroBox,代码行数:26,代码来源:NetworkManager.py

示例9: init_bluez_profile

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import SystemBus [as 别名]
def init_bluez_profile(self):
		print("Configuring Bluez Profile")

		# setup profile options
		service_record = self.read_sdp_service_record()
		opts = {
			"ServiceRecord": service_record,
			"Role": "server",
			"RequireAuthentication": False,
			"RequireAuthorization": False,
			"AutoConnect": True
		}

		# retrieve a proxy for the bluez profile interface
		bus = dbus.SystemBus()
		manager = dbus.Interface(bus.get_object(
		    "org.bluez", "/org/bluez"), "org.bluez.ProfileManager1")
		profile = BTKbBluezProfile(bus, BTKbDevice.PROFILE_DBUS_PATH)
		manager.RegisterProfile("/org/bluez/hci0", BTKbDevice.UUID, opts)
		print("Profile registered ")

	# read and return an sdp record from a file 
开发者ID:quangthanh010290,项目名称:keyboard_mouse_emulate_on_raspberry,代码行数:24,代码来源:btk_server.py

示例10: _check_permission

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

示例11: run_agent

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import SystemBus [as 别名]
def run_agent():
    if GObject:
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        bus = dbus.SystemBus()
        capability = "NoInputNoOutput"

        path = "/test/agent"
        agent = Agent(bus, path)

        mainloop = GObject.MainLoop()

        obj = bus.get_object(BUS_NAME, "/org/bluez")
        manager = dbus.Interface(obj, "org.bluez.AgentManager1")
        manager.RegisterAgent(path, capability)

        print("\n\n[+] Agent registered in background ")

        manager.RequestDefaultAgent(path)
        try:
            mainloop.run()
        except:
            print("\n[-] The agent has finished ")
    else:
        print("No agent running...") 
开发者ID:ElevenPaths,项目名称:HomePWN,代码行数:26,代码来源:dirtyagent.py

示例12: __init__

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import SystemBus [as 别名]
def __init__(self, master, background="white"):
        Frame.__init__(self, master, bg=background)

        self.container = Frame(self, bg=background)
        self.container.pack(side="top")

        self.buttons = []

        for i in xrange(3):
            for j in xrange(3):
                self.buttons.append(Button(self.container, text=str(i * 3 + j + 1)))
                self.buttons[i * 3 + j].bind("<ButtonPress-1>", self.on_press(i, j))
                self.buttons[i * 3 + j].bind("<ButtonRelease-1>", self.on_release)
                self.buttons[i * 3 + j].grid(row=i, column=j, padx=20, pady=20)

        self.bus = dbus.SystemBus()
        self.bluetoothservice = self.bus.get_object('org.upwork.HidBluetoothService', "/org/upwork/HidBluetoothService")
        self.iface = dbus.Interface(self.bluetoothservice, 'org.upwork.HidBluetoothService') 
开发者ID:AnesBenmerzoug,项目名称:Bluetooth_HID,代码行数:20,代码来源:user_interface.py

示例13: init_bluez_profile

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

        print("Configuring Bluez Profile")

        # setup profile options
        service_record = self.read_sdp_service_record()

        opts = {
            "ServiceRecord": service_record,
            "Role": "server",
            "RequireAuthentication": False,
            "RequireAuthorization": False
        }

        # retrieve a proxy for the bluez profile interface
        bus = dbus.SystemBus()
        manager = dbus.Interface(bus.get_object("org.bluez", "/org/bluez"), "org.bluez.ProfileManager1")

        profile = BluetoothBluezProfile(bus, BluetoothDevice.PROFILE_DBUS_PATH)

        manager.RegisterProfile(BluetoothDevice.PROFILE_DBUS_PATH, BluetoothDevice.UUID, opts)

        print("Profile registered ")

    # read and return an sdp record from a file 
开发者ID:AnesBenmerzoug,项目名称:Bluetooth_HID,代码行数:27,代码来源:bluetooth_emulator_server.py

示例14: __init__

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import SystemBus [as 别名]
def __init__(self, adapter_addr, device_addr, profile_uuid):
        """
        Remote GATT Profile Initialisation.

        :param profile_path: dbus path to the profile.
        """
        self.profile_path = dbus_tools.get_profile_path(adapter_addr,
                                                        device_addr,
                                                        profile_uuid)
        self.bus = dbus.SystemBus()
        self.profile_object = self.bus.get_object(
            constants.BLUEZ_SERVICE_NAME,
            self.profile_path)
        self.profile_methods = dbus.Interface(
            self.profile_object,
            constants.GATT_PROFILE_IFACE)
        self.profile_props = dbus.Interface(self.profile_object,
                                            dbus.PROPERTIES_IFACE) 
开发者ID:ukBaz,项目名称:python-bluezero,代码行数:20,代码来源:GATT.py

示例15: __init__

# 需要导入模块: import dbus [as 别名]
# 或者: from dbus import SystemBus [as 别名]
def __init__(self, advert_id, ad_type):
        """Default initialiser.

        Creates the interface to the specified advertising data.
        The DBus path must be specified.

        :param advert_id: Unique ID of advertisement.
        :param ad_type: Possible values: "broadcast" or "peripheral"
        """
        # Setup D-Bus object paths and register service
        self.path = '/ukBaz/bluezero/advertisement{0:04d}'.format(advert_id)
        self.bus = dbus.SystemBus()
        self.eventloop = async_tools.EventLoop()
        self.interface = constants.LE_ADVERTISEMENT_IFACE
        dbus.service.Object.__init__(self, self.bus, self.path)
        self.props = {
            constants.LE_ADVERTISEMENT_IFACE: {
                'Type': ad_type,
                'ServiceUUIDs': None,
                'ManufacturerData': None,
                'SolicitUUIDs': None,
                'ServiceData': None,
                'IncludeTxPower': False
            }
        } 
开发者ID:ukBaz,项目名称:python-bluezero,代码行数:27,代码来源:advertisement.py


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