Browse Source

Modify growler.py for new GNTP module. Fix transmission of icon.

- use 'localhost' for local Growl instead of "None".
- Sending binary icon now works properly, so external icon not needed any more.
- No need to send icon with every message, only when registering.
- Log more info about gntp-error exceptions
tags/0.7.4Beta2
shypike 13 years ago
parent
commit
ec4b613498
  1. 20
      sabnzbd/growler.py

20
sabnzbd/growler.py

@ -64,21 +64,21 @@ NOTIFICATION = {
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Setup platform dependent Growl support # Setup platform dependent Growl support
# #
_GROWL_ICON = None # Platform-dependant icon path
_GROWL = None # Instance of the Notifier after registration _GROWL = None # Instance of the Notifier after registration
_GROWL_REG = False # Succesful registration _GROWL_REG = False # Succesful registration
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
def get_icon(host): def get_icon():
if host is None:
icon = os.path.join(os.path.join(sabnzbd.DIR_PROG, 'icons'), 'sabnzbd.ico') icon = os.path.join(os.path.join(sabnzbd.DIR_PROG, 'icons'), 'sabnzbd.ico')
if not os.path.isfile(icon): if not os.path.isfile(icon):
icon = os.path.join(sabnzbd.DIR_PROG, 'sabnzbd.ico') icon = os.path.join(sabnzbd.DIR_PROG, 'sabnzbd.ico')
if not os.path.isfile(icon): if os.path.isfile(icon):
icon = None fp = open(icon, 'rb')
icon = fp.read()
fp.close
else: else:
icon = 'http://sabnzbdplus.sourceforge.net/version/sabnzbd.ico' icon = None
return icon return icon
@ -148,9 +148,9 @@ def register_growl():
growler = GrowlNotifier( growler = GrowlNotifier(
applicationName = 'SABnzbd%s' % sys_name, applicationName = 'SABnzbd%s' % sys_name,
applicationIcon = get_icon(host or None), applicationIcon = get_icon(),
notifications = [Tx(NOTIFICATION[key]) for key in NOTIFY_KEYS], notifications = [Tx(NOTIFICATION[key]) for key in NOTIFY_KEYS],
hostname = host or None, hostname = host or 'localhost',
port = port or 23053, port = port or 23053,
password = sabnzbd.cfg.growl_password() or None password = sabnzbd.cfg.growl_password() or None
) )
@ -173,6 +173,7 @@ def register_growl():
except: except:
error = 'Unknown Growl registration error' error = 'Unknown Growl registration error'
logging.debug(error) logging.debug(error)
logging.info("Traceback: ", exc_info = True)
del growler del growler
ret = None ret = None
@ -200,9 +201,6 @@ def send_growl(title , msg, gtype):
noteType = Tx(NOTIFICATION.get(gtype, 'other')), noteType = Tx(NOTIFICATION.get(gtype, 'other')),
title = title, title = title,
description = unicoder(msg), description = unicoder(msg),
#icon = options.icon,
#sticky = options.sticky,
#priority = options.priority
) )
if ret is None or isinstance(ret, bool): if ret is None or isinstance(ret, bool):
return None return None

Loading…
Cancel
Save