Urlopen try,except fixes

This commit is contained in:
Ruud committed 2011-11-11 15:47:57 +01:00
1 parent 0420bdeec5
commit 668b95353f
19 files changed
+116 -133

No files matched your search

+6 -6
View File
@@ -79,9 +79,9 @@ class NMJ(Notification):
if self.mount:
log.debug('Try to mount network drive via url: %s' % (mount))
data = self.urlopen(mount)
if not data:
log.error('Warning: Couldn\'t contact popcorn hour on host %s' % host)
try:
data = self.urlopen(mount)
except:
return False
params = {
@@ -94,9 +94,9 @@ class NMJ(Notification):
UPDATE_URL = 'http://%(host)s:8008/metadata_database?%(params)s'
updateUrl = UPDATE_URL % {'host': host, 'params': params}
response = self.urlopen(updateUrl)
if not response:
log.error('Warning: Couldn\'t contact Popcorn Hour on host %s' % host)
try:
response = self.urlopen(updateUrl)
except:
return False
try:
@@ -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__)
@@ -30,8 +31,8 @@ class Notifo(Notification):
if result['status'] != 'success' or result['response_message'] != 'OK':
raise Exception
except Exception, e:
log.error('Notification failed: %s' % e)
except:
log.error('Notification failed: %s' % traceback.format_exc())
return False
log.info('Notifo notification successful.')
+3 -1
View File
@@ -29,7 +29,9 @@ class XBMC(Notification):
'Authorization': "Basic %s" % base64.encodestring('%s:%s' % (self.conf('username'), self.conf('password')))[:-1]
}
if not self.urlopen(url, headers = headers):
try:
self.urlopen(url, headers = headers)
except:
log.error("Couldn't sent command to XBMC")
return False