Commit 2ce3f49a8fbe80a5c92460f904d4e75761669ff8

Authored by Lucas Kanashiro
1 parent dcbb8462

Logged expection in import_email script

src/super_archives/management/commands/import_emails.py
... ... @@ -7,6 +7,7 @@ import os
7 7 import re
8 8 import sys
9 9 import mailbox
  10 +import logging
10 11 from optparse import make_option
11 12  
12 13 from django.db import transaction
... ... @@ -248,7 +249,6 @@ class Command(BaseCommand, object):
248 249 # This anti-pattern is needed to avoid the transations to
249 250 # get stuck in case of errors.
250 251 transaction.rollback()
251   - os.remove(self.lock_file)
252 252 raise
253 253  
254 254 count += 1
... ... @@ -279,8 +279,14 @@ class Command(BaseCommand, object):
279 279 run_lock = file(self.lock_file, 'w')
280 280 run_lock.close()
281 281  
282   - self.import_emails(archives_path,
  282 + try:
  283 + self.import_emails(archives_path,
283 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 291 os.remove(self.lock_file)
286 292  
... ...