Commit 2ce3f49a8fbe80a5c92460f904d4e75761669ff8
1 parent
dcbb8462
Exists in
master
and in
39 other branches
Logged expection in import_email script
Showing
1 changed file
with
8 additions
and
2 deletions
Show diff stats
src/super_archives/management/commands/import_emails.py
@@ -7,6 +7,7 @@ import os | @@ -7,6 +7,7 @@ import os | ||
7 | import re | 7 | import re |
8 | import sys | 8 | import sys |
9 | import mailbox | 9 | import mailbox |
10 | +import logging | ||
10 | from optparse import make_option | 11 | from optparse import make_option |
11 | 12 | ||
12 | from django.db import transaction | 13 | from django.db import transaction |
@@ -248,7 +249,6 @@ class Command(BaseCommand, object): | @@ -248,7 +249,6 @@ class Command(BaseCommand, object): | ||
248 | # This anti-pattern is needed to avoid the transations to | 249 | # This anti-pattern is needed to avoid the transations to |
249 | # get stuck in case of errors. | 250 | # get stuck in case of errors. |
250 | transaction.rollback() | 251 | transaction.rollback() |
251 | - os.remove(self.lock_file) | ||
252 | raise | 252 | raise |
253 | 253 | ||
254 | count += 1 | 254 | count += 1 |
@@ -279,8 +279,14 @@ class Command(BaseCommand, object): | @@ -279,8 +279,14 @@ class Command(BaseCommand, object): | ||
279 | run_lock = file(self.lock_file, 'w') | 279 | run_lock = file(self.lock_file, 'w') |
280 | run_lock.close() | 280 | run_lock.close() |
281 | 281 | ||
282 | - self.import_emails(archives_path, | 282 | + try: |
283 | + self.import_emails(archives_path, | ||
283 | options.get('all'), options.get('exclude_lists')) | 284 | options.get('all'), options.get('exclude_lists')) |
285 | + except Exception, e: | ||
286 | + logging.except(e) | ||
287 | + raise | ||
288 | + finally: | ||
289 | + os.remove(self.lock_file) | ||
284 | 290 | ||
285 | os.remove(self.lock_file) | 291 | os.remove(self.lock_file) |
286 | 292 |