diff options
author | Johan Lundberg <lundberg@nordu.net> | 2014-04-03 11:07:50 +0200 |
---|---|---|
committer | Johan Lundberg <lundberg@nordu.net> | 2014-04-03 11:08:09 +0200 |
commit | be303f3210b9793598692ec22ecf29c6f20f2aba (patch) | |
tree | f2566734994f58b9d01a86b5d46fdd4aeabccbe6 /meetingtools/apps | |
parent | 66fd26d39f7ff820c052803de8cd1b468b718f81 (diff) |
Added catch all error handling for content full import.
Diffstat (limited to 'meetingtools/apps')
-rw-r--r-- | meetingtools/apps/content/tasks.py | 31 |
1 files changed, 22 insertions, 9 deletions
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 |