convert_to_sql: add receipt_time in error_formdata.log; fix typo (#31415)
This commit is contained in:
parent
d32f772c11
commit
c8be054394
|
@ -17,6 +17,7 @@
|
|||
import os
|
||||
import sys
|
||||
import StringIO
|
||||
import psycopg2
|
||||
import traceback
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
|
@ -26,6 +27,7 @@ from qommon.publisher import get_publisher_class
|
|||
|
||||
from wcs import sql
|
||||
from wcs.formdef import FormDef
|
||||
from wcs.qommon.misc import localstrftime
|
||||
from wcs.qommon.storage import atomic_write
|
||||
from wcs.users import User
|
||||
|
||||
|
@ -94,15 +96,17 @@ class Command(BaseCommand):
|
|||
user.store()
|
||||
except AssertionError:
|
||||
errors.append((user, traceback.format_exc()))
|
||||
error_log.write('\n\n')
|
||||
self.update_progress(100*i/count)
|
||||
sql.SqlUser.fix_sequences()
|
||||
|
||||
if errors:
|
||||
error_log = open('error_user.log', 'w')
|
||||
for user, trace in errors:
|
||||
error_log.write('user_id %s' % user.id)
|
||||
error_log.write('user_id %s\n' % user.id)
|
||||
error_log.write(trace)
|
||||
error_log.write('-'*80)
|
||||
error_log.write('\n\n')
|
||||
error_log.close()
|
||||
print('There were some errors, see error_user.log for details.')
|
||||
|
||||
|
@ -130,7 +134,7 @@ class Command(BaseCommand):
|
|||
formdata.__class__ = sql_data_class
|
||||
try:
|
||||
formdata.store()
|
||||
except AssertionError:
|
||||
except (AssertionError, psycopg2.DataError):
|
||||
errors.append((formdata, traceback.format_exc()))
|
||||
self.update_progress(100*i/count)
|
||||
sql_data_class.fix_sequences()
|
||||
|
@ -142,9 +146,12 @@ class Command(BaseCommand):
|
|||
if errors:
|
||||
error_log = open('error_formdata.log', 'w')
|
||||
for formdata, trace in errors:
|
||||
error_log.write('%s %s' % (formdata.fromdef, formdata.id))
|
||||
error_log.write('%s %s - %s\n' % (formdata.formdef,
|
||||
formdata.id,
|
||||
localstrftime(formdata.receipt_time)))
|
||||
error_log.write(trace)
|
||||
error_log.write('-'*80)
|
||||
error_log.write('\n\n')
|
||||
error_log.close()
|
||||
print('There were some errors, see error_formdata.log.')
|
||||
|
||||
|
|
Loading…
Reference in New Issue