print("ERROR: bibsched seems to run with pid %d, according to %s."%(pid,pidfile),file=sys.stderr)
print(" Please stop bibsched before running this procedure.",file=sys.stderr)
sys.exit(1)
ifenable_recstruct_cache:
print(">>> Searching records which need recstruct cache resetting; this may take a while...")
all_recids=intbitset(run_sql("SELECT id FROM bibrec"))
good_recids=intbitset(run_sql("SELECT bibrec.id FROM bibrec JOIN bibfmt ON bibrec.id = bibfmt.id_bibrec WHERE format='recstruct' AND modification_date < last_updated"))
recids=all_recids-good_recids
print(">>> Generating recstruct cache...")
tot=len(recids)
count=0
forrecidinrecids:
try:
value=serialize_via_marshal(get_record(recid))
exceptzlib.error,err:
print>>sys.stderr,"Looks like XM is corrupted for record %s. Let's recover it from bibxxx"%recid
run_sql("DELETE FROM bibfmt WHERE id_bibrec=%s AND format='xm'",(recid,))
xm_value=zlib.compress(print_record(recid,'xm'))
run_sql("INSERT INTO bibfmt(id_bibrec, format, last_updated, value) VALUES(%s, 'xm', NOW(), %s)",(recid,xm_value))
value=serialize_via_marshal(get_record(recid))
run_sql("DELETE FROM bibfmt WHERE id_bibrec=%s AND format='recstruct'",(recid,))
run_sql("INSERT INTO bibfmt(id_bibrec, format, last_updated, value) VALUES(%s, 'recstruct', NOW(), %s)",(recid,value))
"'const' must not be supplied for action %r"%self.action,
self)
CHECK_METHODS=[
Option._check_action,
Option._check_type,
Option._check_choice,
Option._check_dest,
_check_const,
Option._check_nargs,
Option._check_callback,
]
parser=OptionParser(option_class=InvenioOption,description="Invenio configuration and administration CLI tool",formatter=IndentedHelpFormatter(max_help_position=31))
parser.add_option("-V","--version",action="store_true",help="print version number")
finish_options=OptionGroup(parser,"Options to finish your installation")
finish_options.add_option("","--create-secret-key",dest='actions',const='create-secret-key',action="append_const",help="generate random CFG_SITE_SECRET_KEY")
finish_options.add_option("","--load-webstat-conf",dest='actions',const='load-webstat-conf',action="append_const",help="load the WebStat configuration")
finish_options.add_option("","--drop-tables",dest='actions',const='drop-tables',action="append_const",help="drop DB tables of Invenio")
finish_options.add_option("","--check-openoffice",dest='actions',const='check-openoffice',action="append_const",help="check for correctly set up of openoffice temporary directory")
parser.add_option_group(finish_options)
demotest_options=OptionGroup(parser,"Options to set up and test a demo site")
demotest_options.add_option("","--drop-demo-site",dest='actions',const='drop-demo-site',action="append_const",help="drop demo site configurations too")
demotest_options.add_option("","--run-unit-tests",dest='actions',const='run-unit-tests',action="append_const",help="run unit test suite (needs demo site)")
demotest_options.add_option("","--run-js-unit-tests",dest='actions',const='run-js-unit-tests',action="append_const",help="run JS unit test suite (needs demo site)")
demotest_options.add_option("","--run-regression-tests",dest='actions',const='run-regression-tests',action="append_const",help="run regression test suite (needs demo site)")
demotest_options.add_option("","--run-web-tests",dest='actions',const='run-web-tests',action="append_const",help="run web tests in a browser (needs demo site, Firefox, Selenium IDE)")
demotest_options.add_option("","--run-flask-tests",dest='actions',const='run-flask-tests',action="append_const",help="run Flask test suite")
parser.add_option_group(demotest_options)
config_options=OptionGroup(parser,"Options to update config files in situ")
config_options.add_option("","--update-all",dest='actions',const='update-all',action="append_const",help="perform all the update options")
config_options.add_option("","--update-config-py",dest='actions',const='update-config-py',action="append_const",help="update config.py file from invenio.conf file")
config_options.add_option("","--update-dbquery-py",dest='actions',const='update-dbquery-py',action="append_const",help="update dbquery.py with DB credentials from invenio.conf")
config_options.add_option("","--update-dbexec",dest='actions',const='update-dbexec',action="append_const",help="update dbexec with DB credentials from invenio.conf")
config_options.add_option("","--update-bibconvert-tpl",dest='actions',const='update-bibconvert-tpl',action="append_const",help="update bibconvert templates with CFG_SITE_URL from invenio.conf")
config_options.add_option("","--update-web-tests",dest='actions',const='update-web-tests',action="append_const",help="update web test cases with CFG_SITE_URL from invenio.conf")
parser.add_option_group(config_options)
reset_options=OptionGroup(parser,"Options to update DB tables")
reset_options.add_option("","--reset-all",dest='actions',const='reset-all',action="append_const",help="perform all the reset options")
reset_options.add_option("","--reset-sitename",dest='actions',const='reset-sitename',action="append_const",help="reset tables to take account of new CFG_SITE_NAME*")
reset_options.add_option("","--reset-siteadminemail",dest='actions',const='reset-siteadminemail',action="append_const",help="reset tables to take account of new CFG_SITE_ADMIN_EMAIL")
reset_options.add_option("","--reset-fieldnames",dest='actions',const='reset-fieldnames',action="append_const",help="reset tables to take account of new I18N names from PO files")
reset_options.add_option("","--reset-recstruct-cache",dest='actions',const='reset-recstruct-cache',action="append_const",help="reset record structure cache according to CFG_BIBUPLOAD_SERIALIZE_RECORD_STRUCTURE")
reset_options.add_option("","--reset-recjson-cache",dest='actions',const='reset-recjson-cache',action="append_const",help="reset record json structure cache according to CFG_BIBUPLOAD_SERIALIZE_RECORD_STRUCTURE")
parser.add_option_group(reset_options)
upgrade_options=OptionGroup(parser,"Options to upgrade your installation")
upgrade_options.add_option("","--upgrade",dest='actions',const='upgrade',action="append_const",help="apply all pending upgrades")
upgrade_options.add_option("","--upgrade-check",dest='actions',const='upgrade-check',action="append_const",help="run pre-upgrade checks for pending upgrades")
upgrade_options.add_option("","--upgrade-show-applied",dest='actions',const='upgrade-show-applied',action="append_const",help="show history of applied upgrades")
helper_options=OptionGroup(parser,"Options to help the work")
helper_options.add_option("","--list",dest='actions',const='list',action="append_const",help="print names and values of all options from conf files")
helper_options.add_option("","--get",dest='actions',const='get',action="store_append_const",metavar="OPTION",help="get value of a given option from conf files")
helper_options.add_option("","--conf-dir",action="store",metavar="PATH",help="path to directory where invenio*.conf files are [optional]")
helper_options.add_option("","--detect-system-details",dest='actions',const='detect-system-details',action="append_const",help="print system details such as Apache/Python/MySQL versions")
parser.add_option_group(helper_options)
parser.add_option('--yes-i-know',action='store_true',dest='yes-i-know',help='use with care!')
parser.add_option('-x','--stop',action='store_true',dest='stop_on_error',help='When running tests, stop at first error')