Skip to content
Snippets Groups Projects
Verified Commit bd964564 authored by Quentin Duchemin's avatar Quentin Duchemin
Browse files

Better exception handling if Etherpad is down

parent 7fb6d529
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,7 @@ class EtherpadCollector(object):
# Get all instances stats
for instance in self.instances:
print("Etherpad : collecting for instance {}".format(instance['name']))
data = self._get_stats(instance)
if data is None:
continue
......@@ -86,8 +87,11 @@ class EtherpadCollector(object):
:returns: JSON data returned by Etherpad stats module
"""
# Send request
stats_plugin = requests.get(instance['url'] + "/stats.json")
stats_native = requests.get(instance['url'] + "/stats")
try:
stats_plugin = requests.get(instance['url'] + "/stats.json")
stats_native = requests.get(instance['url'] + "/stats")
except requests.exceptions.RequestException as e:
print('Unable to contact Etherpad : {}'.format(e))
if stats_plugin.status_code != 200:
print("Unable to get stats.json from {} : HTTP {}".format(instance['name'], stats_plugin.status_code))
return None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment