-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintrospect_ravelled
executable file
·41 lines (38 loc) · 1.34 KB
/
introspect_ravelled
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python3
#+
# DBussy example -- make an Introspect query to a specified bus object.
# This version uses the structured high-level Ravel API with asyncio.
# Invoke this script as follows:
#
# introspect_ravelled «bus» «bus-name» «obj-path»
#
# where «bus» is either “session” or “system”, indicating which bus
# to do the query on, “bus-name” is the name of the service on the
# bus to query, and «obj-path» is the path of the object to query.
# The response should be an XML string in the usual introspection
# format, indicating the protocol for communicating with the
# specified object.
#
# Copyright 2017 by Lawrence D'Oliveiro <[email protected]>. This
# script is licensed CC0
# <https://creativecommons.org/publicdomain/zero/1.0/>; do with it
# what you will.
#-
import sys
import getopt
import dbussy as dbus
from dbussy import \
DBUS
import ravel
if len(sys.argv) != 4 :
raise getopt.GetoptError("usage: %s session|system «bus-name» «obj-path»" % sys.argv[0])
#end if
bus = {"session" : ravel.session_bus, "system" : ravel.system_bus}[sys.argv[1].lower()]()
bus.attach_asyncio()
interface = bus.loop.run_until_complete \
(
bus[sys.argv[2]][sys.argv[3]]
.get_async_interface(DBUS.INTERFACE_INTROSPECTABLE)
)
reply = bus.loop.run_until_complete(interface.Introspect())
sys.stdout.write(reply[0])