print(wrap_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)
recids=retrieve_fulltext_recids()
print(wrap_text_in_a_box("""This script migrate the filesystem structure used to store fulltext 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'))
print("%s records will be migrated/fixed."%len(recids))
print("Please type yes if you want to go further:",end=' ')
ifnotcheck_yes():
print("INTERRUPTED")
sys.exit(1)
print("Backing up database tables")
try:
ifnotbackup_tables():
print(wrap_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'))
print("Please, type yes if you agree to remove them and go further:",end=' ')
print("Backing up database tables (after dropping previous backup)",end=' ')
backup_tables(drop=True)
print("-> OK")
else:
print("-> OK")
exceptExceptionase:
print(wrap_text_in_a_box("Unexpected error while backing up tables. Please, do your checks: %s"%e,style='conclusion'))
sys.exit(1)
print("Created a complete log file into %s"%logfilename)
forrecidinrecids:
ifnotfix_recid(recid,logfile):
logfile.close()
print(wrap_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,recid,CFG_SITE_SUPPORT_EMAIL),