diff --git a/portail_citoyen/apps/data_source_plugin/cms_plugins.py b/portail_citoyen/apps/data_source_plugin/cms_plugins.py index 9594d83..f79d826 100644 --- a/portail_citoyen/apps/data_source_plugin/cms_plugins.py +++ b/portail_citoyen/apps/data_source_plugin/cms_plugins.py @@ -11,7 +11,7 @@ from django.template import Template import feedparser import requests -from requests.exceptions import RequestException, HTTPError +from requests.exceptions import RequestException, HTTPError, Timeout from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool @@ -45,6 +45,7 @@ class Data(object): def update_content(self): + content = None try: self.final_url = self.url if self.data_source.signature_key: @@ -64,20 +65,20 @@ class Data(object): except HTTPError: logger.warning('HTTP Error %s when loading datasource %s from' ' URL %s', request.status_code, self.data_source.id, self.final_url) - content = None + except Timeout: + logger.warning('HTTP Request timeout(%s s) when loading datasource' + ' %s from URL %s', self.data_source.timeout, + self.data_source.id, self.final_url) except RequestException: logger.warning('HTTP Request failed when loading datasource' ' %s from URL %s', self.data_source.id, self.final_url) - content = None except Exception: logger.exception('Unkown exception when loading datasource %s' ' from URL %s', self.data_source.id, self.final_url) - content = None else: try: content = getattr(self, 'get_content_'+self.kind)(request) except Exception: - content = None logger.exception('decoding of content from %s failed', self.final_url) else: logger.debug('getting data source %r from url %r finished',