From: Ross Jones Date: Fri, 11 Oct 2013 14:58:52 +0000 Subject: Typoe X-Git-Url: http://maxious.lambdacomplex.org/git/?p=ckanext-ga-report.git&a=commitdiff&h=26263f359e95ac344b8e8358c0a0028fa39d66da --- Typoe --- --- a/ckanext/ga_report/download_analytics.py +++ b/ckanext/ga_report/download_analytics.py @@ -258,24 +258,22 @@ return data def _get_json(self, params, prev_fail=False): - if prev_fail: - import os - ga_token_filepath = os.path.expanduser(config.get('googleanalytics.token.filepath', '')) - 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: - self.token, svc = init_service(ga_token_filepath, None) - except TypeError: - print ('Have you correctly run the getauthtoken task and ' - 'specified the correct token file in the CKAN config under ' - '"googleanalytics.token.filepath"?') - - try: - # Because of issues of invalid responses, we are going to make these requests - # ourselves. + ga_token_filepath = os.path.expanduser(config.get('googleanalytics.token.filepath', '')) + 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") + self.token, svc = init_service(ga_token_filepath, None) + log.info("OAuth token refreshed") + except Exception, auth_exception: + log.error("Oauth refresh failed") + log.exception(auth_exception) + return + + try: 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: @@ -285,10 +283,6 @@ return json.loads(r.content) except Exception, e: - if not prev_fail: - print e - results = self._get_json(self, params, prev_fail=True) - else: log.exception(e) return dict(url=[]) --- a/ckanext/ga_report/templates/ga_report/publisher/index.html +++ b/ckanext/ga_report/templates/ga_report/publisher/index.html @@ -9,9 +9,9 @@ - + ${ga_sidebar(download_link=h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='publisher_csv',month=c.month or 'all'))} - + --- a/ckanext/ga_report/templates/ga_report/publisher/read.html +++ b/ckanext/ga_report/templates/ga_report/publisher/read.html @@ -19,9 +19,9 @@ - + ${ga_sidebar(download_link=h.url_for(controller='ckanext.ga_report.controller:GaDatasetReport',action='dataset_csv',id=c.publisher_name or 'all',month=c.month or 'all'))} - + Site Usage ${usage_nav('Datasets')}
--- a/ckanext/ga_report/templates/ga_report/site/downloads.html +++ b/ckanext/ga_report/templates/ga_report/site/downloads.html @@ -7,9 +7,9 @@ Downloads - + ${ga_sidebar(download_link=h.url_for(controller='ckanext.ga_report.controller:GaReport',action='csv_downloads',month=c.month or 'all'))} - + Downloads ${usage_nav('Downloads')}
--- a/ckanext/ga_report/templates/ga_report/site/index.html +++ b/ckanext/ga_report/templates/ga_report/site/index.html @@ -19,9 +19,9 @@ - + ${ga_sidebar(download_link=h.url_for(controller='ckanext.ga_report.controller:GaReport',action='csv',month=c.month or 'all'))} - + Site Usage ${usage_nav('Site-wide')} @@ -168,7 +168,7 @@ CKAN.GA_Reports.bind_sparklines(); CKAN.GA_Reports.bind_sidebar(); CKAN.GA_Reports.bind_month_selector(); - }); + });