forked from openlp/openlp
Let's catch also all errors when response from remote is not correct JSON or it does not contain required item.
This commit is contained in:
parent
4ed5c33584
commit
5cd7162cec
@ -426,7 +426,10 @@ class HttpConnection(object):
|
|||||||
"""
|
"""
|
||||||
Send an alert.
|
Send an alert.
|
||||||
"""
|
"""
|
||||||
text = json.loads(self.url_params[u'data'][0])[u'request'][u'text']
|
try:
|
||||||
|
text = json.loads(self.url_params[u'data'][0])[u'request'][u'text']
|
||||||
|
except ValueError:
|
||||||
|
return HttpResponse(code=u'400 Bad Request')
|
||||||
text = urllib.unquote(text)
|
text = urllib.unquote(text)
|
||||||
Receiver.send_message(u'alerts_text', [text])
|
Receiver.send_message(u'alerts_text', [text])
|
||||||
return HttpResponse(json.dumps({u'results': {u'success': True}}),
|
return HttpResponse(json.dumps({u'results': {u'success': True}}),
|
||||||
@ -468,7 +471,10 @@ class HttpConnection(object):
|
|||||||
json_data[u'results'][u'item'] = self.parent.current_item._uuid
|
json_data[u'results'][u'item'] = self.parent.current_item._uuid
|
||||||
else:
|
else:
|
||||||
if self.url_params and self.url_params.get(u'data'):
|
if self.url_params and self.url_params.get(u'data'):
|
||||||
data = json.loads(self.url_params[u'data'][0])
|
try:
|
||||||
|
data = json.loads(self.url_params[u'data'][0])
|
||||||
|
except ValueError:
|
||||||
|
return HttpResponse(code=u'400 Bad Request')
|
||||||
log.info(data)
|
log.info(data)
|
||||||
# This slot expects an int within a list.
|
# This slot expects an int within a list.
|
||||||
id = data[u'request'][u'id']
|
id = data[u'request'][u'id']
|
||||||
@ -488,7 +494,10 @@ class HttpConnection(object):
|
|||||||
else:
|
else:
|
||||||
event += u'_item'
|
event += u'_item'
|
||||||
if self.url_params and self.url_params.get(u'data'):
|
if self.url_params and self.url_params.get(u'data'):
|
||||||
data = json.loads(self.url_params[u'data'][0])
|
try:
|
||||||
|
data = json.loads(self.url_params[u'data'][0])
|
||||||
|
except ValueError:
|
||||||
|
return HttpResponse(code=u'400 Bad Request')
|
||||||
Receiver.send_message(event, data[u'request'][u'id'])
|
Receiver.send_message(event, data[u'request'][u'id'])
|
||||||
else:
|
else:
|
||||||
Receiver.send_message(event)
|
Receiver.send_message(event)
|
||||||
@ -521,7 +530,10 @@ class HttpConnection(object):
|
|||||||
``type``
|
``type``
|
||||||
The plugin name to search in.
|
The plugin name to search in.
|
||||||
"""
|
"""
|
||||||
text = json.loads(self.url_params[u'data'][0])[u'request'][u'text']
|
try:
|
||||||
|
text = json.loads(self.url_params[u'data'][0])[u'request'][u'text']
|
||||||
|
except ValueError:
|
||||||
|
return HttpResponse(code=u'400 Bad Request')
|
||||||
text = urllib.unquote(text)
|
text = urllib.unquote(text)
|
||||||
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
|
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
|
||||||
if plugin.status == PluginStatus.Active and \
|
if plugin.status == PluginStatus.Active and \
|
||||||
@ -537,7 +549,10 @@ class HttpConnection(object):
|
|||||||
"""
|
"""
|
||||||
Go live on an item of type ``type``.
|
Go live on an item of type ``type``.
|
||||||
"""
|
"""
|
||||||
id = json.loads(self.url_params[u'data'][0])[u'request'][u'id']
|
try:
|
||||||
|
id = json.loads(self.url_params[u'data'][0])[u'request'][u'id']
|
||||||
|
except ValueError:
|
||||||
|
return HttpResponse(code=u'400 Bad Request')
|
||||||
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
|
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
|
||||||
if plugin.status == PluginStatus.Active and plugin.mediaItem:
|
if plugin.status == PluginStatus.Active and plugin.mediaItem:
|
||||||
plugin.mediaItem.goLive(id, remote=True)
|
plugin.mediaItem.goLive(id, remote=True)
|
||||||
@ -547,7 +562,10 @@ class HttpConnection(object):
|
|||||||
"""
|
"""
|
||||||
Add item of type ``type`` to the end of the service.
|
Add item of type ``type`` to the end of the service.
|
||||||
"""
|
"""
|
||||||
id = json.loads(self.url_params[u'data'][0])[u'request'][u'id']
|
try:
|
||||||
|
id = json.loads(self.url_params[u'data'][0])[u'request'][u'id']
|
||||||
|
except ValueError:
|
||||||
|
return HttpResponse(code=u'400 Bad Request')
|
||||||
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
|
plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type)
|
||||||
if plugin.status == PluginStatus.Active and plugin.mediaItem:
|
if plugin.status == PluginStatus.Active and plugin.mediaItem:
|
||||||
item_id = plugin.mediaItem.createItemFromId(id)
|
item_id = plugin.mediaItem.createItemFromId(id)
|
||||||
|
Loading…
Reference in New Issue
Block a user