summaryrefslogtreecommitdiffstats
path: root/tools/dbus_exporter.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
commit55944e5e40b1be2afc4855d8d2baf4b73d1876b5 (patch)
tree33f869f55a1b149e9b7c2b7e201867ca5dd52992 /tools/dbus_exporter.py
parentInitial commit. (diff)
downloadsystemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.tar.xz
systemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.zip
Adding upstream version 255.4.upstream/255.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/dbus_exporter.py')
-rwxr-xr-xtools/dbus_exporter.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/dbus_exporter.py b/tools/dbus_exporter.py
new file mode 100755
index 0000000..819584d
--- /dev/null
+++ b/tools/dbus_exporter.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+from argparse import ArgumentParser
+from pathlib import Path
+from subprocess import PIPE, run
+
+
+def extract_interfaces_xml(output_dir, executable):
+ proc = run(
+ args=[executable.absolute(), '--bus-introspect', 'list'],
+ stdout=PIPE,
+ check=True,
+ universal_newlines=True)
+
+ interface_names = (x.split()[1] for x in proc.stdout.splitlines())
+
+ for interface_name in interface_names:
+ proc = run(
+ args=[executable.absolute(), '--bus-introspect', interface_name],
+ stdout=PIPE,
+ check=True,
+ universal_newlines=True)
+
+ interface_file_name = output_dir / (interface_name + '.xml')
+ interface_file_name.write_text(proc.stdout)
+ interface_file_name.chmod(0o644)
+
+def main():
+ parser = ArgumentParser()
+ parser.add_argument('output',
+ type=Path)
+ parser.add_argument('executables',
+ nargs='+',
+ type=Path)
+
+ args = parser.parse_args()
+
+ args.output.mkdir(exist_ok=True)
+ for exe in args.executables:
+ extract_interfaces_xml(args.output, exe)
+
+if __name__ == '__main__':
+ main()