From ca5fad3915a420efb14d08bd4ef375f34647ca8d Mon Sep 17 00:00:00 2001 From: Raoul Scholtes Date: Sat, 25 Sep 2021 21:18:09 +0200 Subject: [PATCH] properly fix #24 using try/catch statement --- Vailyn | 10 ++++++++-- core/methods/notify.py | 20 +++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Vailyn b/Vailyn index 6030409..600df60 100755 --- a/Vailyn +++ b/Vailyn @@ -40,7 +40,10 @@ import sys if adv_li: import setproctitle - import notify2 + try: + import notify2 + except ModuleNotFoundError: + pass # initialize colorama @@ -67,7 +70,10 @@ if __name__ == "__main__": if variables.adv_li and DESKTOP_NOTIFY: # initialize notifications - notify2.init("Vailyn") + try: + notify2.init("Vailyn") + except NameError: + pass # set global variables and determine # main method diff --git a/core/methods/notify.py b/core/methods/notify.py index 4362f0c..9ffbe2f 100644 --- a/core/methods/notify.py +++ b/core/methods/notify.py @@ -26,7 +26,10 @@ from core.variables import SEPARATOR if variables.adv_li and DESKTOP_NOTIFY: - import notify2 + try: + import notify2 + except ModuleNotFoundError: + pass def notify(message): @@ -48,10 +51,13 @@ def notify(message): "tid.png", ]) - notification = notify2.Notification( - "Vailyn", - message=message, - icon=icon, - ) + try: + notification = notify2.Notification( + "Vailyn", + message=message, + icon=icon, + ) - notification.show() + notification.show() + except NameError: + pass