mirror of
https://github.com/lucaspalomodevelop/indico-plugins.git
synced 2026-03-15 08:24:35 +00:00
Handle Piwik error response
This commit is contained in:
parent
ca33b238b6
commit
9dc709dc95
@ -40,7 +40,6 @@ class PiwikQueryReportEventMetricDownloads(PiwikQueryReportEventMetricBase):
|
||||
def _get_per_day_results(self, results):
|
||||
hits_calendar = {}
|
||||
|
||||
# Piwik returns hits as a list of hits per date
|
||||
for date, hits in results.iteritems():
|
||||
day_hits = {'total': 0, 'unique': 0}
|
||||
if hits:
|
||||
|
||||
@ -10,7 +10,11 @@ def get_json_from_remote_server(func, default={}, **kwargs):
|
||||
"""
|
||||
rawjson = func(**kwargs)
|
||||
try:
|
||||
return json.loads(rawjson)
|
||||
data = json.loads(rawjson)
|
||||
if isinstance(data, dict) and data.get('result') == 'error':
|
||||
current_plugin.get_logger().error('The Piwik server responded with an error: {}'.format(data['message']))
|
||||
return {}
|
||||
return data
|
||||
except Exception:
|
||||
current_plugin.get_logger().exception('Unable to load JSON from source {}'.format(str(rawjson)))
|
||||
return default
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user