You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.6 KiB

13 years ago
from couchpotato.core.event import fireEvent
14 years ago
from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification
from gntp import notifier
import logging
13 years ago
import thread
import time
import traceback
14 years ago
log = CPLog(__name__)
class Growl(Notification):
def __init__(self):
super(Growl, self).__init__()
14 years ago
logging.getLogger('gntp').setLevel(logging.WARNING)
14 years ago
try:
13 years ago
def startGrowl():
time.sleep(2)
try:
self.growl = notifier.GrowlNotifier(
applicationName = 'CouchPotato',
notifications = ["Updates"],
defaultNotifications = ["Updates"],
applicationIcon = '%s/static/images/couch.png' % fireEvent('app.api_url', single = True),
)
self.growl.register()
except:
log.error('Failed register of growl: %s' % traceback.format_exc())
thread.start_new_thread(startGrowl, ())
except:
pass
14 years ago
def notify(self, type = '', message = '', data = {}):
if self.isDisabled(): return
14 years ago
try:
self.growl.notify(
noteType = "Updates",
title = self.default_title,
description = message,
sticky = False,
priority = 1,
)
14 years ago
log.info('Growl notifications sent.')
return True
except:
log.error('Failed growl notification.')
return False