printwrap_text_in_a_box('NOTE: it\'s impossible to create the log:\n\n%s\n\nbecause of:\n\n%s\n\nPlease run this migration kit as the same user who runs Invenio (e.g. Apache)'%(logfilename,e),style='conclusion',break_long=False)
sys.exit(1)
bibdoc_bibdoc=retrieve_bibdoc_bibdoc()
printwrap_text_in_a_box("""This script migrate the filesystem structure used to store icons files to the new stricter structure.
This script must not be run during normal Invenio operations.
It is safe to run this script. No file will be deleted.
Anyway it is recommended to run a backup of the filesystem structure just in case.
A backup of the database tables involved will be automatically performed.""",style='important')
ifnotbibdoc_bibdoc:
printwrap_text_in_a_box("No need for migration",style='conclusion')
return
print"%s icons will be migrated/fixed."%len(bibdoc_bibdoc)
wait_for_user()
print"Backing up database tables"
try:
ifnotbackup_tables():
printwrap_text_in_a_box("""It appears that is not the first time that you run this script.
Backup tables have been already created by a previous run.
In order for the script to go further they need to be removed.""",style='important')
wait_for_user()
print"Backing up database tables (after dropping previous backup)",
backup_tables(drop=True)
print"-> OK"
else:
print"-> OK"
exceptException,e:
printwrap_text_in_a_box("Unexpected error while backing up tables. Please, do your checks: %s"%e,style='conclusion')
sys.exit(1)
to_fix_marc=intbitset()
print"Created a complete log file into %s"%logfilename
printwrap_text_in_a_box(title="INTERRUPTED BECAUSE OF ERROR!",body="""Please see the log file %s for what was the status of record %s prior to the error. Contact %s in case of problems, attaching the log."""%(logfilename,BibDoc(id_bibdoc1).get_recid(),CFG_SITE_SUPPORT_EMAIL),
style='conclusion')
sys.exit(1)
finally:
print"Scheduling FIX-MARC to synchronize MARCXML for updated records."