## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. import sys from invenio.config import CFG_SITE_SECRET_KEY from invenio.scriptutils import Manager, change_command_name, \ generate_secret_key, register_manager from invenio.sqlalchemyutils import db from invenio.webinterface_handler_flask import create_invenio_flask_app # Fixes problems with empty secret key in config manager. if 'config' in sys.argv and \ (not CFG_SITE_SECRET_KEY or CFG_SITE_SECRET_KEY == ''): create_invenio_flask_app = create_invenio_flask_app( SECRET_KEY=generate_secret_key()) manager = Manager(create_invenio_flask_app, with_default_commands=False) register_manager(manager) @manager.shell def make_shell_context(): """Extend shell context.""" from flask import current_app return dict(current_app=current_app, db=db) @manager.command def version(): """ Get running version of Invenio """ from invenio.config import CFG_VERSION return CFG_VERSION
## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. from invenio.scriptutils import Manager, change_command_name manager = Manager(usage="Perform Apache operations.") @manager.command def version(separator='\n'): """ Try to detect Apache version by localizing httpd or apache executables and grepping inside binaries. Return list of all found Apache versions and paths. (For a given executable, the returned format is 'apache_version [apache_path]'.) Return empty list if no success. """ from invenio.inveniocfg import _grep_version_from_executable from invenio.shellutils import run_shell_command out = [] dummy1, cmd_out, dummy2 = run_shell_command("locate bin/httpd bin/apache")
## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. import os import sys from invenio.scriptutils import Manager manager = Manager(usage="Perform demosite operations") # Shortcuts for manager options to keep code DRY. option_yes_i_know = manager.option('--yes-i-know', action='store_true', dest='yes_i_know', help='use with care!') option_default_data = manager.option( '--no-data', action='store_false', dest='default_data', help='do not populate tables with default data') @option_default_data def populate(default_data=True):
## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. from invenio.scriptutils import Manager manager = Manager(usage="Perform BibConvert operations") @manager.command def update(): """Updates BibConvert templates. Update bibconvert/config/*.tpl files looking for 856 http://.../CFG_SITE_RECORD lines, replacing URL with CFG_SITE_URL taken from conf file. Note: this edits tpl files in situ, taking a backup first. Use only when you know what you are doing. """ print ">>> Going to update bibconvert templates..." import os import re import shutil
## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. from invenio.scriptutils import Manager manager = Manager(usage="Perform BibRecord operations") # Define sub-manager bibrecord_cache = Manager(usage="Manipulates BibRecord cache.") # Add sub-manager manager.add_command("cache", bibrecord_cache) @bibrecord_cache.command def reset(split_by=1000): """Reset bibrecord structure cache.""" from invenio.bibedit_model import Bibfmt from invenio.cache_manager import reset_rec_cache from invenio.dbquery import run_sql, serialize_via_marshal from invenio.search_engine import get_record
## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. from invenio.scriptutils import Manager, change_command_name, \ generate_secret_key manager = Manager(usage="Perform configuration operations") def get_conf(): try: from invenio.config import CFG_ETCDIR except: CFG_ETCDIR = None from invenio.inveniocfg import prepare_conf class TmpOptions(object): conf_dir = CFG_ETCDIR return prepare_conf(TmpOptions())
## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. from invenio.scriptutils import Manager manager = Manager(usage="Perform BibField operations") # Define sub-managers bibfield_config = Manager(usage="Manipulates BibField config.") bibfield_cache = Manager(usage="Manipulates BibField cache.") # Add sub-managers manager.add_command("config", bibfield_config) manager.add_command("cache", bibfield_cache) @bibfield_config.command def load(): """Loads BibField config.""" print ">>> Going to load BibField config..." from invenio.bibfield_config_engine import BibFieldParser
""" Invenio template migration engine. Migrates output formats and output templates found in CFG_BIBFORMAT_OUTPUTS_PATH and CFG_BIBFORMAT_TEMPLATES_PATH respectively. It creates backup of each output format with name `<FORMAT>_legacy.bfo` and generates new Jinja2 templates in CFG_BIBFORMAT_JINJA_TEMPLATE_PATH. """ import os import re import shutil from invenio.scriptutils import Manager manager = Manager(usage="Perform migration operations") @manager.option('--rewrite-existing-templates', dest='rewrite_existing_templates', action='store_true', default=False) @manager.option('-t', '--template', dest='only_template_re', default=None, help="only templates matching regular expression") @manager.option('--verbose', dest='verbose') def bft2tpl(rewrite_existing_templates=False, only_template_re=None, verbose=0): """Converts bft templates to Jinja2 templates.""" ## Import all invenio modules inside to avoid side-efects ouside ## Flask application context. from invenio.bibformat_config import CFG_BIBFORMAT_OUTPUTS_PATH, \
## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. from invenio.scriptutils import Manager, change_command_name manager = Manager(usage="Perform cache operations") def reset_rec_cache(output_format, get_record, split_by=1000): """It either stores or does not store the output_format. If CFG_BIBUPLOAD_SERIALIZE_RECORD_STRUCTURE is changed, this function will adapt the database to either store or not store the output_format.""" import sys try: import cPickle as pickle except: import pickle from itertools import islice from invenio.config import CFG_BIBUPLOAD_SERIALIZE_RECORD_STRUCTURE
## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. from invenio.scriptutils import Manager manager = Manager(usage="Perform upgrade engine operations.") @manager.command def run(): """ Command for applying upgrades """ from invenio.inveniocfg_upgrader import cmd_upgrade cmd_upgrade() @manager.command def check(): """ Command for checking upgrades