diff options
Diffstat (limited to 'meetingtools')
-rw-r--r-- | meetingtools/ac/api.py | 2 | ||||
-rw-r--r-- | meetingtools/apps/content/tasks.py | 31 |
2 files changed, 23 insertions, 10 deletions
diff --git a/meetingtools/ac/api.py b/meetingtools/ac/api.py index 6ec2904..5254163 100644 --- a/meetingtools/ac/api.py +++ b/meetingtools/ac/api.py @@ -153,7 +153,7 @@ class ACPClient(): url = self.url + '?' + '&'.join(u) #cache = ACPClient.CacheWrapper(get_cache('default')) cache = None - h = httplib2.Http(cache, disable_ssl_certificate_validation=True); + h = httplib2.Http(cache, disable_ssl_certificate_validation=True) logging.debug(url) resp, content = h.request(url, "GET") logging.debug(pformat(resp)) diff --git a/meetingtools/apps/content/tasks.py b/meetingtools/apps/content/tasks.py index 16feb34..f7eb1c4 100644 --- a/meetingtools/apps/content/tasks.py +++ b/meetingtools/apps/content/tasks.py @@ -2,6 +2,7 @@ __author__ = 'lundberg' from meetingtools.ac import ac_api_client +from meetingtools.ac.api import ACPException from meetingtools.apps.content.models import Content import logging from datetime import datetime, timedelta @@ -37,16 +38,28 @@ def import_all_content(): def timed_full_import(): years = [2009, 2010, 2011, 2012, 2013, 2014] for acc in ACCluster.objects.all(): + nr = 0 for year in years: begin = datetime(year=year, month=1, day=1) end = datetime(year=year, month=12, day=31) with ac_api_client(acc) as api: - r = api.request('report-bulk-objects', {'filter-out-type': 'meeting', - 'filter-gte-date-modified': begin.isoformat(), - 'filter-lte-date-modified': end.isoformat()}) - if r: - nr = 0 - for row in r.et.xpath("//row"): - Content.create(acc, api, row) - nr += 1 - logging.info("%s: Imported %d objects." % (acc, nr))
\ No newline at end of file + try: + r = api.request('report-bulk-objects', + {'filter-out-type': 'meeting', + 'filter-gte-date-modified': begin.isoformat(), + 'filter-lte-date-modified': end.isoformat()}, + raise_error=True) + if r: + nr = 0 + for row in r.et.xpath("//row"): + Content.create(acc, api, row) + nr += 1 + except ACPException as e: + logging.error('ACPException in content.timed_full_import') + logging.error(e) + pass + except Exception as e: + logging.error('Exception in content.timed_full_import') + logging.error(e) + pass + logging.info("%s: Imported %d objects." % (acc, nr))
\ No newline at end of file |