Add missing import, explains why it was broken before
--- a/ckanext/ga_report/download_analytics.py
+++ b/ckanext/ga_report/download_analytics.py
@@ -262,10 +262,11 @@
if not ga_token_filepath:
print 'ERROR: In the CKAN config you need to specify the filepath of the ' \
'Google Analytics token file under key: googleanalytics.token.filepath'
- return
-
- try:
- log.info("Trying to refresh our OAuth token")
+ return
+
+ log.info("Trying to refresh our OAuth token")
+ try:
+ from ga_auth import init_service
self.token, svc = init_service(ga_token_filepath, None)
log.info("OAuth token refreshed")
except Exception, auth_exception:
@@ -277,9 +278,9 @@
headers = {'authorization': 'Bearer ' + self.token}
r = requests.get("https://www.googleapis.com/analytics/v3/data/ga", params=params, headers=headers)
if r.status_code != 200:
- log.info("STATUS: %s" % (r.status_code,))
- log.info("CONTENT: %s" % (r.content,))
- raise Exception("Request with params: %s failed" % params)
+ log.info("STATUS: %s" % (r.status_code,))
+ log.info("CONTENT: %s" % (r.content,))
+ raise Exception("Request with params: %s failed" % params)
return json.loads(r.content)
except Exception, e: