Add some error handling to sabnzbd statuscheck

This commit is contained in:
Ruud committed 2012-09-22 09:20:37 +02:00
1 parent 5776b2caad
commit 6fc9d383de
1 file changed
+7 -1
+7 -1
View File
@@ -2,8 +2,8 @@ from couchpotato.core.downloaders.base import Downloader
from couchpotato.core.helpers.encoding import tryUrlencode from couchpotato.core.helpers.encoding import tryUrlencode
from couchpotato.core.helpers.variable import cleanHost from couchpotato.core.helpers.variable import cleanHost
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
import traceback
import json import json
import traceback
log = CPLog(__name__) log = CPLog(__name__)
@@ -91,10 +91,13 @@ class Sabnzbd(Downloader):
log.error('Failed parsing json status: %s', traceback.format_exc()) log.error('Failed parsing json status: %s', traceback.format_exc())
return False return False
try:
for slot in history['queue']['slots']: for slot in history['queue']['slots']:
log.debug('Found %s in SabNZBd queue, which is %s, with %s left', (slot['filename'], slot['status'], slot['timeleft'])) log.debug('Found %s in SabNZBd queue, which is %s, with %s left', (slot['filename'], slot['status'], slot['timeleft']))
if slot['filename'] == nzbname: if slot['filename'] == nzbname:
return slot['status'].lower() return slot['status'].lower()
except:
log.debug('No items in queue: %s', (traceback.format_exc()))
# Go through history items # Go through history items
params = { params = {
@@ -118,6 +121,7 @@ class Sabnzbd(Downloader):
log.error('Failed parsing history json: %s', traceback.format_exc()) log.error('Failed parsing history json: %s', traceback.format_exc())
return return
try:
for slot in history['history']['slots']: for slot in history['history']['slots']:
log.debug('Found %s in SabNZBd history, which has %s', (slot['name'], slot['status'])) log.debug('Found %s in SabNZBd history, which has %s', (slot['name'], slot['status']))
if slot['name'] == nzbname: if slot['name'] == nzbname:
@@ -158,5 +162,7 @@ class Sabnzbd(Downloader):
return 'failed' return 'failed'
else: else:
return slot['status'].lower() return slot['status'].lower()
except:
log.debug('No items in history: %s', (traceback.format_exc()))
return 'not_found' return 'not_found'