import argparse
import logging
import socket
+import xml.parsers.expat
import dbus
import dbus.service
s2.close()
return s1, s3
+def list_objects(bus, busname, path=None):
+ """List objects on the given bus and busname starting with path. Only the
+ trailing components after the slash are returned.
+
+ @type bus: dbus.Bus
+ @type busname: str
+ @type path: None or str
+ @param path: prefix for searching objects. Defaults to
+ dbusutils.object_prefix.
+ @rtype: [str]
+ @returns: the trailing components of the objects found
+ """
+ if path is None:
+ path = object_prefix
+ xmlstring = bus.get_object(busname, path).Introspect()
+ parser = xml.parsers.expat.ParserCreate()
+ nodes = []
+ def start_element(name, attrs):
+ if name != "node":
+ return
+ try:
+ value = attrs["name"]
+ except KeyError:
+ return
+ nodes.append(value)
+ parser.StartElementHandler = start_element
+ parser.Parse(xmlstring)
+ return nodes
+
class OnoffControl(dbus.service.Object):
domain = default_busname
path = object_prefix