File: context.py

package info (click to toggle)
pydbus 0.6.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,332 kB
  • sloc: python: 1,023; sh: 25; makefile: 15
file content (39 lines) | stat: -rw-r--r-- 694 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
33
34
35
36
37
38
39
from pydbus import SessionBus, connect
import os

DBUS_SESSION_BUS_ADDRESS = os.getenv("DBUS_SESSION_BUS_ADDRESS")

with connect(DBUS_SESSION_BUS_ADDRESS) as bus:
	bus.dbus

del bus._dbus
try:
	bus.dbus
	assert(False)
except RuntimeError:
	pass

with SessionBus() as bus:
	pass

# SessionBus() and SystemBus() are not closed automatically, so this should work:
bus.dbus

with bus.request_name("net.lew21.Test"):
	pass

with bus.request_name("net.lew21.Test"):
	pass

with bus.request_name("net.lew21.Test"):
	try:
		bus.request_name("net.lew21.Test")
		assert(False)
	except RuntimeError:
		pass

with bus.watch_name("net.lew21.Test"):
	pass

with bus.subscribe(sender="net.lew21.Test"):
	pass