From: Ross Jones Date: Fri, 11 Oct 2013 15:19:34 +0000 Subject: Add missing import, explains why it was broken before X-Git-Url: http://maxious.lambdacomplex.org/git/?p=ckanext-ga-report.git&a=commitdiff&h=731608debd15904966e8825a743e994643f45172 --- Add missing import, explains why it was broken before --- --- a/ckanext/ga_report/download_analytics.py +++ b/ckanext/ga_report/download_analytics.py @@ -262,13 +262,14 @@ 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: + except Exception, auth_exception: log.error("Oauth refresh failed") log.exception(auth_exception) return @@ -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: