File: glib-list-names.py

package info (click to toggle)
python-dbus-next 0.2.3-6
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 704 kB
  • sloc: python: 6,018; makefile: 45; xml: 29
file content (32 lines) | stat: -rwxr-xr-x 613 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env python3
import sys
import os

sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/..'))

from dbus_next import Message
from dbus_next.glib import MessageBus

import json
import signal
from gi.repository import GLib

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()