Skip to content

Commit

Permalink
Prevent crashing when Hamster is not installed
Browse files Browse the repository at this point in the history
fixes #683
  • Loading branch information
diegogangl committed Jul 3, 2024
1 parent 6470b85 commit 05e22c9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions GTG/plugins/hamster/hamster.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------

import logging
import datetime
import os
import time
Expand All @@ -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'
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 05e22c9

Please sign in to comment.