try: the_bibdoc = BibDoc(id_bibdoc1) except Exception, err: msg = "WARNING: when opening docid %s: %s" % (id_bibdoc1, err) print >> logfile, msg print msg return True try: recid = the_bibdoc.get_recid() msg = "Fixing icon for recid %s: document %s (docid %s)" % (recid, the_bibdoc.get_docname(), id_bibdoc1) print msg, print >> logfile, msg, the_icon = BibDoc(id_bibdoc2) for a_file in the_icon.list_latest_files(): the_bibdoc.add_icon(a_file.get_full_path(), format=a_file.get_format()) the_icon.delete() run_sql("DELETE FROM bibdoc_bibdoc WHERE id_bibdoc1=%s AND id_bibdoc2=%s", (id_bibdoc1, id_bibdoc2)) print "OK" print >> logfile, "OK" return True except Exception, err: print "ERROR: %s" % err print >> logfile, "ERROR: %s" % err register_exception() return False def main(): """Core loop.""" check_running_process_user() logfilename = '%s/fulltext_files_migration_kit-%s.log' % (CFG_LOGDIR, datetime.today().strftime('%Y%m%d%H%M%S')) try:
except Exception, err: msg = "WARNING: when opening docid %s: %s" % (id_bibdoc1, err) print >> logfile, msg print msg return True try: recid = the_bibdoc.get_recid() msg = "Fixing icon for recid %s: document %s (docid %s)" % ( recid, the_bibdoc.get_docname(), id_bibdoc1) print msg, print >> logfile, msg, the_icon = BibDoc(id_bibdoc2) for a_file in the_icon.list_latest_files(): the_bibdoc.add_icon(a_file.get_full_path(), format=a_file.get_format()) the_icon.delete() run_sql( "DELETE FROM bibdoc_bibdoc WHERE id_bibdoc1=%s AND id_bibdoc2=%s", (id_bibdoc1, id_bibdoc2)) print "OK" print >> logfile, "OK" return True except Exception, err: print "ERROR: %s" % err print >> logfile, "ERROR: %s" % err register_exception() return False def main(): """Core loop."""