From 655e847aebc3535087e184ecfdaf5e4e906e551e Mon Sep 17 00:00:00 2001 From: Ruud Date: Sat, 10 Nov 2012 10:10:05 +0100 Subject: [PATCH] Catch renamer.after event errors. fix #1032 --- couchpotato/core/notifications/xbmc/main.py | 24 ++++++++++++++------- couchpotato/core/plugins/renamer/main.py | 5 ++++- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/couchpotato/core/notifications/xbmc/main.py b/couchpotato/core/notifications/xbmc/main.py index a2a81d70..96bb2cf8 100755 --- a/couchpotato/core/notifications/xbmc/main.py +++ b/couchpotato/core/notifications/xbmc/main.py @@ -3,6 +3,7 @@ from couchpotato.core.logger import CPLog from couchpotato.core.notifications.base import Notification from flask.helpers import json import base64 +import traceback log = CPLog(__name__) @@ -22,9 +23,12 @@ class XBMC(Notification): ('VideoLibrary.Scan', {}), ]) - for result in response: - if result['result'] == "OK": - successful += 1 + try: + for result in response: + if result['result'] == "OK": + successful += 1 + except: + log.error('Failed parsing results: %s', traceback.format_exc()) return successful == len(hosts) * 2 @@ -50,10 +54,14 @@ class XBMC(Notification): base64string = base64.encodestring('%s:%s' % (self.conf('username'), self.conf('password'))).replace('\n', '') headers['Authorization'] = 'Basic %s' % base64string - log.debug('Sending request to %s: %s', (host, data)) - rdata = self.urlopen(server, headers = headers, params = data, multipart = True) - response = json.loads(rdata) - log.debug('Returned from request %s: %s', (host, response)) + try: + log.debug('Sending request to %s: %s', (host, data)) + rdata = self.urlopen(server, headers = headers, params = data, multipart = True) + response = json.loads(rdata) + log.debug('Returned from request %s: %s', (host, response)) - return response + return response + except: + log.error('Failed sending request to XBMC: %s', traceback.format_exc()) + return [] diff --git a/couchpotato/core/plugins/renamer/main.py b/couchpotato/core/plugins/renamer/main.py index 207af6b3..a10725b9 100644 --- a/couchpotato/core/plugins/renamer/main.py +++ b/couchpotato/core/plugins/renamer/main.py @@ -383,7 +383,10 @@ class Renamer(Plugin): # Notify on download, search for trailers etc download_message = 'Downloaded %s (%s)' % (movie_title, replacements['quality']) - fireEvent('renamer.after', message = download_message, group = group, in_order = True) + try: + fireEvent('renamer.after', message = download_message, group = group, in_order = True) + except: + log.error('Failed firing (some) of the renamer.after events: %s', traceback.format_exc()) # Break if CP wants to shut down if self.shuttingDown():