dbus-fast/examples/glib-list-names.py
pre-commit-ci[bot] bfc8151005
chore(pre-commit.ci): pre-commit autoupdate (#427)
* chore(pre-commit.ci): pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.1.0 → v0.11.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.1.0...v0.11.0)

* chore(pre-commit.ci): auto fixes

* chore: fix violations

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
2025-03-17 11:01:24 -10:00

40 lines
655 B
Python
Executable File

#!/usr/bin/env python3
import os
import sys
sys.path.append(os.path.abspath(os.path.dirname(__file__) + "/.."))
import json
import signal
from gi.repository import GLib
from dbus_fast import Message
from dbus_fast.glib import MessageBus
main = GLib.MainLoop()
bus = MessageBus().connect_sync()
def reply_handler(reply, err):
main.quit()
if err:
raise err
print(json.dumps(reply.body[0], indent=2))
bus.call(
Message(
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
"ListNames",
),
reply_handler,
)
signal.signal(signal.SIGINT, signal.SIG_DFL)
main.run()