- commit
- d423f854ed683902f690d454b67cfa74adf934eb
- parent
- e172df4b756c48c363c6413bf2edc64f9c8d4530
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2026-02-16 08:41
add send_reply
Diffstat
| M | xibus/connection.py | 28 | ++++++++++++++++++++++++++++ |
1 files changed, 28 insertions, 0 deletions
diff --git a/xibus/connection.py b/xibus/connection.py
@@ -202,6 +202,34 @@ class Connection: 202 202 203 203 await self.send(*msg.marshal()) 204 204 -1 205 async def send_reply(self, call, handler): -1 206 try: -1 207 sig, body = await handler(call) -1 208 reply = Msg( -1 209 MsgType.METHOD_RETURN, -1 210 self.get_serial(), -1 211 reply_serial=call.serial, -1 212 destination=call.sender, -1 213 body=body, -1 214 sig=sig, -1 215 ) -1 216 except Exception as e: -1 217 # TODO: better error conversion -1 218 # (what is the quivalent of 404 not found?) -1 219 reply = Msg( -1 220 MsgType.ERROR, -1 221 self.get_serial(), -1 222 reply_serial=call.serial, -1 223 destination=call.sender, -1 224 error_name='org.freedesktop.DBus.Error.AccessDenied', -1 225 body=(str(e),), -1 226 sig='s', -1 227 ) -1 228 -1 229 if not call.flags & MsgFlag.NO_REPLY_EXPECTED: -1 230 await self.send(*reply.marshal()) -1 231 -1 232 205 233 def get_connection(bus): 206 234 if bus == 'session': 207 235 addr = os.getenv(