From 05e22c98b2b599f61ba5afff210575c25f569fcd Mon Sep 17 00:00:00 2001 From: Diego Garcia Gangl Date: Wed, 3 Jul 2024 19:33:39 -0300 Subject: [PATCH] Prevent crashing when Hamster is not installed fixes #683 --- GTG/plugins/hamster/hamster.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/GTG/plugins/hamster/hamster.py b/GTG/plugins/hamster/hamster.py index c0494d8cc..d4dbbc103 100644 --- a/GTG/plugins/hamster/hamster.py +++ b/GTG/plugins/hamster/hamster.py @@ -16,6 +16,7 @@ # this program. If not, see . # ----------------------------------------------------------------------------- +import logging import datetime import os import time @@ -28,6 +29,7 @@ from GTG.core.tasks import Task from GTG.plugins.hamster.helper import FactBuilder +log = logging.getLogger(__name__) class HamsterPlugin(): PLUGIN_NAMESPACE = 'hamster-plugin' @@ -150,8 +152,13 @@ def on_task_modified(self, task_id, path): # Plugin api methods ### def activate(self, plugin_api): self.plugin_api = plugin_api - self.hamster = dbus.SessionBus().get_object('org.gnome.Hamster', - '/org/gnome/Hamster') + + try: + self.hamster = dbus.SessionBus().get_object('org.gnome.Hamster', + '/org/gnome/Hamster') + except dbus.exceptions.DBusException: + log.error('Hamster plugin failed to activate. Is Hamster installed?') + return # add button if plugin_api.is_browser():