File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 5
5
from wakepy .core import DbusAdapter , DbusMethodCall
6
6
7
7
8
+ class DbusNotFoundError (RuntimeError ):
9
+ ...
10
+
11
+
8
12
class JeepneyDbusAdapter (DbusAdapter ):
9
13
"""An implementation of DbusAdapter using jeepney. Can be used to process
10
14
DbusMethodCalls (communication with Dbus services over a dbus-daemon)."""
@@ -25,7 +29,18 @@ def process(self, call: DbusMethodCall):
25
29
signature = call .method .signature ,
26
30
body = call .args ,
27
31
)
28
- connection = open_dbus_connection (bus = call .method .bus )
32
+ try :
33
+ connection = open_dbus_connection (bus = call .method .bus )
34
+ except KeyError as exc :
35
+ if "DBUS_SESSION_BUS_ADDRESS" in str (exc ):
36
+ raise DbusNotFoundError (
37
+ "The environment variable DBUS_SESSION_BUS_ADDRESS is not set! "
38
+ "To use dbus-based methods with jeepney, a session (not system) "
39
+ "bus (dbus-daemon process) must be running, and the address of the "
40
+ "bus should be available at the DBUS_SESSION_BUS_ADDRESS "
41
+ "environment variable. To check if you're running a session "
42
+ "dbus-daemon, run `ps -x | grep dbus-daemon`"
43
+ ) from exc
29
44
reply = connection .send_and_get_reply (msg , timeout = self .timeout )
30
45
resp = unwrap_msg (reply )
31
46
return resp
You can’t perform that action at this time.
0 commit comments