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>
|
<div class="muted">Nothing is currently being watched.</div><br>
|
||||||
% endif
|
% endif
|
||||||
% else:
|
% 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
|
% endif
|
|
@ -116,7 +116,7 @@
|
||||||
"language": {
|
"language": {
|
||||||
"search": "Search: ",
|
"search": "Search: ",
|
||||||
"lengthMenu":"Show _MENU_ entries per page",
|
"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",
|
"infoEmpty":"Showing 0 to 0 of 0 entries",
|
||||||
"infoFiltered":"(filtered from _MAX_ total entries)",
|
"infoFiltered":"(filtered from _MAX_ total entries)",
|
||||||
"emptyTable": "No data in table",
|
"emptyTable": "No data in table",
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="currentActivity">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -33,7 +33,9 @@
|
||||||
<h3>Recently Added</h3>
|
<h3>Recently Added</h3>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
</div>
|
</div>
|
||||||
<footer></footer>
|
<footer></footer>
|
||||||
|
|
|
@ -80,9 +80,8 @@
|
||||||
},
|
},
|
||||||
"sPaginationType": "bootstrap",
|
"sPaginationType": "bootstrap",
|
||||||
"order": [ 0, 'desc'],
|
"order": [ 0, 'desc'],
|
||||||
"pageLength": 25,
|
"pageLength": 10,
|
||||||
"stateSave": true,
|
"stateSave": true,
|
||||||
"autoWidth": true,
|
|
||||||
"language": {
|
"language": {
|
||||||
"search":"Search: ",
|
"search":"Search: ",
|
||||||
"lengthMenu":"Show _MENU_ lines per page",
|
"lengthMenu":"Show _MENU_ lines per page",
|
||||||
|
@ -91,9 +90,17 @@
|
||||||
"infoEmpty":"Showing 0 to 0 of 0 lines",
|
"infoEmpty":"Showing 0 to 0 of 0 lines",
|
||||||
"infoFiltered":"(filtered from _MAX_ total lines)"},
|
"infoFiltered":"(filtered from _MAX_ total lines)"},
|
||||||
"columnDefs": [
|
"columnDefs": [
|
||||||
|
{
|
||||||
|
"targets": [0],
|
||||||
|
"width": "15%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"targets": [1],
|
||||||
|
"width": "10%"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"targets": [2],
|
"targets": [2],
|
||||||
"width": "70%"
|
"width": "75%"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"drawCallback": function (settings) {
|
"drawCallback": function (settings) {
|
||||||
|
|
|
@ -32,5 +32,5 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
% else:
|
% 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
|
% endif
|
|
@ -55,7 +55,7 @@
|
||||||
"language": {
|
"language": {
|
||||||
"search": "Search: ",
|
"search": "Search: ",
|
||||||
"lengthMenu":"Show _MENU_ entries per page",
|
"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",
|
"infoEmpty":"Showing 0 to 0 of 0 entries",
|
||||||
"infoFiltered":"(filtered from _MAX_ total entries)",
|
"infoFiltered":"(filtered from _MAX_ total entries)",
|
||||||
"emptyTable": "No data in table",
|
"emptyTable": "No data in table",
|
||||||
|
|
|
@ -65,17 +65,25 @@ class PmsConnect(object):
|
||||||
url_command = '/status/sessions'
|
url_command = '/status/sessions'
|
||||||
http_handler = HTTPConnection(self.host, self.port, timeout=10)
|
http_handler = HTTPConnection(self.host, self.port, timeout=10)
|
||||||
|
|
||||||
http_handler.request("GET", url_command + '?X-Plex-Token=' + self.token)
|
try:
|
||||||
response = http_handler.getresponse()
|
http_handler.request("GET", url_command + '?X-Plex-Token=' + self.token)
|
||||||
request_status = response.status
|
response = http_handler.getresponse()
|
||||||
request_content = response.read()
|
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':
|
if request_status == 200:
|
||||||
output = helpers.convert_xml_to_dict(request_content)
|
if output_format == 'dict':
|
||||||
elif output_format == 'json':
|
output = helpers.convert_xml_to_dict(request_content)
|
||||||
output = helpers.convert_xml_to_json(request_content)
|
elif output_format == 'json':
|
||||||
|
output = helpers.convert_xml_to_json(request_content)
|
||||||
|
else:
|
||||||
|
output = request_content
|
||||||
else:
|
else:
|
||||||
output = request_content
|
logger.warn(u"Failed to access sessions. Status code %r" % request_status)
|
||||||
|
return None
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
@ -91,17 +99,25 @@ class PmsConnect(object):
|
||||||
url_command = '/library/metadata/' + rating_key
|
url_command = '/library/metadata/' + rating_key
|
||||||
http_handler = HTTPConnection(self.host, self.port, timeout=10)
|
http_handler = HTTPConnection(self.host, self.port, timeout=10)
|
||||||
|
|
||||||
http_handler.request("GET", url_command + '?X-Plex-Token=' + self.token)
|
try:
|
||||||
response = http_handler.getresponse()
|
http_handler.request("GET", url_command + '?X-Plex-Token=' + self.token)
|
||||||
request_status = response.status
|
response = http_handler.getresponse()
|
||||||
request_content = response.read()
|
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':
|
if request_status == 200:
|
||||||
output = helpers.convert_xml_to_dict(request_content)
|
if output_format == 'dict':
|
||||||
elif output_format == 'json':
|
output = helpers.convert_xml_to_dict(request_content)
|
||||||
output = helpers.convert_xml_to_json(request_content)
|
elif output_format == 'json':
|
||||||
|
output = helpers.convert_xml_to_json(request_content)
|
||||||
|
else:
|
||||||
|
output = request_content
|
||||||
else:
|
else:
|
||||||
output = request_content
|
logger.warn(u"Failed to access metadata. Status code %r" % request_status)
|
||||||
|
return None
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
@ -117,17 +133,25 @@ class PmsConnect(object):
|
||||||
url_command = '/library/recentlyAdded?X-Plex-Container-Start=0&X-Plex-Container-Size=' + count
|
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 = HTTPConnection(self.host, self.port, timeout=10)
|
||||||
|
|
||||||
http_handler.request("GET", url_command + '&X-Plex-Token=' + self.token)
|
try:
|
||||||
response = http_handler.getresponse()
|
http_handler.request("GET", url_command + '&X-Plex-Token=' + self.token)
|
||||||
request_status = response.status
|
response = http_handler.getresponse()
|
||||||
request_content = response.read()
|
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':
|
if request_status == 200:
|
||||||
output = helpers.convert_xml_to_dict(request_content)
|
if output_format == 'dict':
|
||||||
elif output_format == 'json':
|
output = helpers.convert_xml_to_dict(request_content)
|
||||||
output = helpers.convert_xml_to_json(request_content)
|
elif output_format == 'json':
|
||||||
|
output = helpers.convert_xml_to_json(request_content)
|
||||||
|
else:
|
||||||
|
output = request_content
|
||||||
else:
|
else:
|
||||||
output = request_content
|
logger.warn(u"Failed to access recently added. Status code %r" % request_status)
|
||||||
|
return None
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
@ -546,7 +570,6 @@ class PmsConnect(object):
|
||||||
request_status = response.status
|
request_status = response.status
|
||||||
request_content = response.read()
|
request_content = response.read()
|
||||||
request_content_type = response.getheader('content-type')
|
request_content_type = response.getheader('content-type')
|
||||||
logger.debug(u"Content type: %r" % request_content_type)
|
|
||||||
except IOError, e:
|
except IOError, e:
|
||||||
logger.warn(u"Failed to retrieve image. %s" % e)
|
logger.warn(u"Failed to retrieve image. %s" % e)
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -699,7 +699,7 @@ class WebInterface(object):
|
||||||
try:
|
try:
|
||||||
pms_connect = pmsconnect.PmsConnect()
|
pms_connect = pmsconnect.PmsConnect()
|
||||||
result = pms_connect.get_image(img, width, height)
|
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]
|
cherrypy.response.headers['Content-type'] = result[0]
|
||||||
return result[1]
|
return result[1]
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue