From 8d839ef3cfdcb8c3351d6e0a79c50c15215a2805 Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Thu, 25 Sep 2014 15:16:05 +0200 Subject: [PATCH] Fix unicode characters in Growl messages. Fixes #1695 --- headphones/notifiers.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/headphones/notifiers.py b/headphones/notifiers.py index 5858eb40..517f35e2 100644 --- a/headphones/notifiers.py +++ b/headphones/notifiers.py @@ -41,7 +41,7 @@ except ImportError: class GROWL(object): """ - Growl notifications, for OS X + Growl notifications, for OS X. """ def __init__(self): @@ -84,14 +84,18 @@ class GROWL(object): try: growl.register() except gntp.notifier.errors.NetworkError: - logger.info(u'Growl notification failed: network error') + logger.warning(u'Growl notification failed: network error') return except gntp.notifier.errors.AuthError: - logger.info(u'Growl notification failed: authentication error') + logger.warning(u'Growl notification failed: authentication error') return + # Fix message + message = message.encode(headphones.SYS_ENCODING, "replace") + # Send it, including an image - image_file = os.path.join(str(headphones.PROG_DIR), 'data/images/headphoneslogo.png') + image_file = os.path.join(str(headphones.PROG_DIR), + "data/images/headphoneslogo.png") with open(image_file, 'rb') as f: image = f.read() @@ -104,7 +108,7 @@ class GROWL(object): icon=image ) except gntp.notifier.errors.NetworkError: - logger.info(u'Growl notification failed: network error') + logger.warning(u'Growl notification failed: network error') return logger.info(u"Growl notifications sent.")