print>>sys.stderr,"ERROR: bibsched seems to run with pid %d, according to %s."%(pid,pidfile)
print>>sys.stderr," Please stop bibsched before running this procedure."
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:
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))
finish_options.add_option("","--create-tables",dest='actions',const='create-tables',action="append_const",help="create DB tables for Invenio")
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-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)")
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")
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")
upgrade_options.add_option("","--upgrade-create-standard-recipe",dest='actions',metavar='REPOSITORY[,DIR]',const='upgrade-create-standard-recipe',action="store_append_const",help="create a new standard upgrade recipe (for developers)")
upgrade_options.add_option("","--upgrade-create-release-recipe",dest='actions',metavar='REPOSITORY[,DIR]',const='upgrade-create-release-recipe',action="store_append_const",help="create a new release upgrade recipe (for developers)")
parser.add_option_group(upgrade_options)
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!')
returnparser
defprepare_conf(options):
""" Read configuration files """
conf=ConfigParser()
confdir=getattr(options,'conf_dir',None)
ifconfdirisNone:
## try to detect path to conf dir (relative to this bin dir):
confdir=re.sub(r'/bin$','/etc',sys.path[0])
ifconfdirandnotos.path.exists(confdir):
raiseException("ERROR: bad --conf-dir option value - directory does not exists.")