If we fail to parse a response, log the uri

and the original response
This commit is contained in:
Hellowlol 2015-09-29 11:28:04 +02:00 committed by John
parent f7bc208fd1
commit b1e27d9bc2

View file

@ -1,3 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of PlexPy.
#
# PlexPy is free software: you can redistribute it and/or modify
@ -14,12 +17,11 @@
# along with PlexPy. If not, see <http://www.gnu.org/licenses/>.
from plexpy import logger, helpers
from httplib import HTTPSConnection
from httplib import HTTPConnection
import ssl
class HTTPHandler(object):
"""
Retrieve data from Plex Server
@ -88,6 +90,7 @@ class HTTPHandler(object):
return None
if request_status == 200:
try:
if output_format == 'dict':
output = helpers.convert_xml_to_dict(request_content)
elif output_format == 'json':
@ -101,6 +104,11 @@ class HTTPHandler(object):
return output, content_type
return output
except Exception as e:
logger.warn(u"Failed format response from uri %s to %s error %s" % (uri, output_format, e))
return None
else:
logger.warn(u"Failed to access uri endpoint %s. Status code %r" % (uri, request_status))
return None