From ffd707db6269419408226e7568abfb264f0ec792 Mon Sep 17 00:00:00 2001 From: Guillermo Rodriguez Date: Mon, 13 Feb 2023 17:47:16 -0300 Subject: [PATCH] Add try catch for when notify-send is not present on system --- piker/ui/_notify.py | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/piker/ui/_notify.py b/piker/ui/_notify.py index bfff686e..c14b3cbb 100644 --- a/piker/ui/_notify.py +++ b/piker/ui/_notify.py @@ -83,22 +83,26 @@ async def notify_from_ems_status_msg( f'unix:path=/run/user/{_dbus_uid}/bus' ) - result = await trio.run_process( - [ - 'notify-send', - '-u', 'normal', - '-t', f'{duration}', - 'piker', + try: + result = await trio.run_process( + [ + 'notify-send', + '-u', 'normal', + '-t', f'{duration}', + 'piker', - # TODO: add in standard fill/exec info that maybe we - # pack in a broker independent way? - f"'{msg.pformat()}'", - ], - capture_stdout=True, - capture_stderr=True, - check=False, - ) - if result.returncode != 0: - log.warn(f'No notification daemon installed stderr: {result.stderr}') - - log.runtime(result) + # TODO: add in standard fill/exec info that maybe we + # pack in a broker independent way? + f"'{msg.pformat()}'", + ], + capture_stdout=True, + capture_stderr=True, + check=False, + ) + if result.returncode != 0: + log.warn(f'Notification daemon crashed stderr: {result.stderr}') + + log.runtime(result) + + except FileNotFoundError: + log.warn('Tried to send a notification but \'notify-send\' not present')