mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-06 05:01:14 -07:00
Improve some error handling of http requests.
Provide more helpful error messages. Some visual fixes.
This commit is contained in:
parent
473ea7513c
commit
21fca0ef89
8 changed files with 70 additions and 38 deletions
|
@ -95,5 +95,5 @@
|
|||
<div class="muted">Nothing is currently being watched.</div><br>
|
||||
% endif
|
||||
% else:
|
||||
<div class="muted">There was an error communicating with your Plex Server. Please check your settings.</div><br>
|
||||
<div class="muted">There was an error communicating with your Plex Server. Please check your <a href="config">settings</a>.</div><br>
|
||||
% endif
|
|
@ -116,7 +116,7 @@
|
|||
"language": {
|
||||
"search": "Search: ",
|
||||
"lengthMenu":"Show _MENU_ entries per page",
|
||||
"info":"Showing _START_ to _END_ of _TOTAL_ entries",
|
||||
"info":"Showing _START_ to _END_ of _TOTAL_ history items",
|
||||
"infoEmpty":"Showing 0 to 0 of 0 entries",
|
||||
"infoFiltered":"(filtered from _MAX_ total entries)",
|
||||
"emptyTable": "No data in table",
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div id="currentActivity">
|
||||
<div class="muted">Checking for activity...</div><br>
|
||||
<div class="muted"><i class="fa fa-refresh fa-spin"></i> Checking for activity...</div><br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -33,7 +33,9 @@
|
|||
<h3>Recently Added</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div id='recentlyAdded'><div id='recently-added-spinner' class='spinner'></div></div>
|
||||
<div id='recentlyAdded'>
|
||||
<div class='muted'><i class="fa fa-refresh fa-spin"></i> Looking for new items...</div><br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer></footer>
|
||||
|
|
|
@ -80,9 +80,8 @@
|
|||
},
|
||||
"sPaginationType": "bootstrap",
|
||||
"order": [ 0, 'desc'],
|
||||
"pageLength": 25,
|
||||
"pageLength": 10,
|
||||
"stateSave": true,
|
||||
"autoWidth": true,
|
||||
"language": {
|
||||
"search":"Search: ",
|
||||
"lengthMenu":"Show _MENU_ lines per page",
|
||||
|
@ -91,9 +90,17 @@
|
|||
"infoEmpty":"Showing 0 to 0 of 0 lines",
|
||||
"infoFiltered":"(filtered from _MAX_ total lines)"},
|
||||
"columnDefs": [
|
||||
{
|
||||
"targets": [0],
|
||||
"width": "15%"
|
||||
},
|
||||
{
|
||||
"targets": [1],
|
||||
"width": "10%"
|
||||
},
|
||||
{
|
||||
"targets": [2],
|
||||
"width": "70%"
|
||||
"width": "75%"
|
||||
}
|
||||
],
|
||||
"drawCallback": function (settings) {
|
||||
|
|
|
@ -32,5 +32,5 @@
|
|||
</ul>
|
||||
</div>
|
||||
% else:
|
||||
<h4>No recently added items.</h4>
|
||||
<div class="muted">There was an error communicating with your Plex Server. Please check your <a href="config">settings</a>.</div><br>
|
||||
% endif
|
|
@ -55,7 +55,7 @@
|
|||
"language": {
|
||||
"search": "Search: ",
|
||||
"lengthMenu":"Show _MENU_ entries per page",
|
||||
"info":"Showing _START_ to _END_ of _TOTAL_ entries",
|
||||
"info":"Showing _START_ to _END_ of _TOTAL_ active users",
|
||||
"infoEmpty":"Showing 0 to 0 of 0 entries",
|
||||
"infoFiltered":"(filtered from _MAX_ total entries)",
|
||||
"emptyTable": "No data in table",
|
||||
|
|
|
@ -65,17 +65,25 @@ class PmsConnect(object):
|
|||
url_command = '/status/sessions'
|
||||
http_handler = HTTPConnection(self.host, self.port, timeout=10)
|
||||
|
||||
http_handler.request("GET", url_command + '?X-Plex-Token=' + self.token)
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
request_content = response.read()
|
||||
try:
|
||||
http_handler.request("GET", url_command + '?X-Plex-Token=' + self.token)
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
request_content = response.read()
|
||||
except IOError, e:
|
||||
logger.warn(u"Failed to access sessions. %s" % e)
|
||||
return None
|
||||
|
||||
if output_format == 'dict':
|
||||
output = helpers.convert_xml_to_dict(request_content)
|
||||
elif output_format == 'json':
|
||||
output = helpers.convert_xml_to_json(request_content)
|
||||
if request_status == 200:
|
||||
if output_format == 'dict':
|
||||
output = helpers.convert_xml_to_dict(request_content)
|
||||
elif output_format == 'json':
|
||||
output = helpers.convert_xml_to_json(request_content)
|
||||
else:
|
||||
output = request_content
|
||||
else:
|
||||
output = request_content
|
||||
logger.warn(u"Failed to access sessions. Status code %r" % request_status)
|
||||
return None
|
||||
|
||||
return output
|
||||
|
||||
|
@ -91,17 +99,25 @@ class PmsConnect(object):
|
|||
url_command = '/library/metadata/' + rating_key
|
||||
http_handler = HTTPConnection(self.host, self.port, timeout=10)
|
||||
|
||||
http_handler.request("GET", url_command + '?X-Plex-Token=' + self.token)
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
request_content = response.read()
|
||||
try:
|
||||
http_handler.request("GET", url_command + '?X-Plex-Token=' + self.token)
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
request_content = response.read()
|
||||
except IOError, e:
|
||||
logger.warn(u"Failed to access metadata. %s" % e)
|
||||
return None
|
||||
|
||||
if output_format == 'dict':
|
||||
output = helpers.convert_xml_to_dict(request_content)
|
||||
elif output_format == 'json':
|
||||
output = helpers.convert_xml_to_json(request_content)
|
||||
if request_status == 200:
|
||||
if output_format == 'dict':
|
||||
output = helpers.convert_xml_to_dict(request_content)
|
||||
elif output_format == 'json':
|
||||
output = helpers.convert_xml_to_json(request_content)
|
||||
else:
|
||||
output = request_content
|
||||
else:
|
||||
output = request_content
|
||||
logger.warn(u"Failed to access metadata. Status code %r" % request_status)
|
||||
return None
|
||||
|
||||
return output
|
||||
|
||||
|
@ -117,17 +133,25 @@ class PmsConnect(object):
|
|||
url_command = '/library/recentlyAdded?X-Plex-Container-Start=0&X-Plex-Container-Size=' + count
|
||||
http_handler = HTTPConnection(self.host, self.port, timeout=10)
|
||||
|
||||
http_handler.request("GET", url_command + '&X-Plex-Token=' + self.token)
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
request_content = response.read()
|
||||
try:
|
||||
http_handler.request("GET", url_command + '&X-Plex-Token=' + self.token)
|
||||
response = http_handler.getresponse()
|
||||
request_status = response.status
|
||||
request_content = response.read()
|
||||
except IOError, e:
|
||||
logger.warn(u"Failed to access recently added items. %s" % e)
|
||||
return None
|
||||
|
||||
if output_format == 'dict':
|
||||
output = helpers.convert_xml_to_dict(request_content)
|
||||
elif output_format == 'json':
|
||||
output = helpers.convert_xml_to_json(request_content)
|
||||
if request_status == 200:
|
||||
if output_format == 'dict':
|
||||
output = helpers.convert_xml_to_dict(request_content)
|
||||
elif output_format == 'json':
|
||||
output = helpers.convert_xml_to_json(request_content)
|
||||
else:
|
||||
output = request_content
|
||||
else:
|
||||
output = request_content
|
||||
logger.warn(u"Failed to access recently added. Status code %r" % request_status)
|
||||
return None
|
||||
|
||||
return output
|
||||
|
||||
|
@ -546,7 +570,6 @@ class PmsConnect(object):
|
|||
request_status = response.status
|
||||
request_content = response.read()
|
||||
request_content_type = response.getheader('content-type')
|
||||
logger.debug(u"Content type: %r" % request_content_type)
|
||||
except IOError, e:
|
||||
logger.warn(u"Failed to retrieve image. %s" % e)
|
||||
return None
|
||||
|
|
|
@ -699,7 +699,7 @@ class WebInterface(object):
|
|||
try:
|
||||
pms_connect = pmsconnect.PmsConnect()
|
||||
result = pms_connect.get_image(img, width, height)
|
||||
logger.info('Image proxy queried. Content type is %s' % result[0])
|
||||
logger.debug(u'Image proxy queried. Content type is %s' % result[0])
|
||||
cherrypy.response.headers['Content-type'] = result[0]
|
||||
return result[1]
|
||||
except:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue