예제 #1
0
warnings.warn(
    "Use of `inveniomanage demosite populate` is being deprecated. "
    "Please use `uploader` module to insert demo records.",
    PendingDeprecationWarning,
)

import os
import pkg_resources
import sys

from itertools import count

from invenio.ext.script import Manager

manager = Manager(usage=__doc__)

# 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_file = manager.option("-f", "--file", dest="files", action="append", help="data file to use")
option_jobid = manager.option("-j", "--job-id", dest="job_id", type=int, default=0, help="bibsched starting job id")
option_extrainfo = manager.option(
    "-e", "--extra-info", dest="extra_info", action="append", help="extraneous parameters"
)
option_packages = manager.option(
    "-p", "--packages", dest="packages", action="append", default=[], help="package import name (repeteable)"
)
예제 #2
0
"""Manage checker module."""

import sys

from functools import wraps

from .common import ALL
from .recids import ids_from_input
from .registry import plugin_files
from .models import CheckerRule, CheckerRecord
from invenio.base.factory import create_app
from invenio.ext.script import Manager, change_command_name
from invenio.ext.sqlalchemy import db

manager = Manager(usage=__doc__)
rules_dec = manager.option('--rules', '-r', default=ALL,
                           help='Comma seperated list of rule names to load,'
                           ' or `{}` for all rules.'.format(ALL))


def interpret_dry_run(func):
    """Resolve `dry_run` to variables understood by `run()`."""
    @wraps(func)
    def _dry_run(*args, **kwargs):
        if 'dry_run' in kwargs:
            if kwargs['dry_run']:
                kwargs['upload'] = False
                kwargs['tickets'] = False
            del kwargs['dry_run']
        return func(*args, **kwargs)
예제 #3
0
import warnings

import pkg_resources

from itertools import count

from invenio.base.utils import run_py_func
from invenio.ext.script import Manager
from invenio.modules.scheduler.models import SchTASK

warnings.warn(
    "Use of `inveniomanage demosite populate` is being deprecated. "
    "Please use `inveniomanage records create`.", DeprecationWarning)

manager = Manager(usage=__doc__)

# 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_file = manager.option('-f',
                             '--file',
                             dest='files',
                             action='append',
예제 #4
0
# 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.

"""Invenio manager implementation using *Flask-Script*."""

from __future__ import print_function

from flask import current_app
from invenio.base.factory import create_app
from invenio.ext.script import Manager, change_command_name, register_manager

manager = Manager(create_app(), with_default_commands=False)


@manager.shell
def make_shell_context():
    """Extend shell context."""
    from invenio.ext.sqlalchemy import db
    return dict(current_app=current_app, db=db)


@manager.command
def version():
    """Get running version of Invenio."""
    return current_app.config.get('CFG_VERSION')

예제 #5
0
import datetime

import os

import sys

from pipes import quote

from flask import current_app

from invenio.ext.script import Manager, change_command_name, print_progress

from six import iteritems

manager = Manager(usage="Perform database 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_quiet = manager.option("--quiet", action="store_true", dest="quiet", help="show less output")
option_default_data = manager.option(
    "--no-data", action="store_false", dest="default_data", help="do not populate tables with default data"
)


@manager.option("-u", "--user", dest="user", default="root")
@manager.option("-p", "--password", dest="password", default="")
@option_yes_i_know
def init(user="******", password="", yes_i_know=False):
    """Initialize database and user."""
    from invenio.ext.sqlalchemy import db
예제 #6
0
파일: manage.py 프로젝트: dset0x/invenio
# 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.

"""Perform record archiving operations."""

from invenio.ext.script import Manager

manager = Manager(usage=__doc__)

option_recid = manager.option("recid", metavar='RECID', type=int,
                              help="Record identifier")
option_version = manager.option("--version", dest="version", type=int,
                                default=-1, help="Version or archived record.")


@option_recid
def create(recid):
    """Create an archive of record."""
    from .api import create_archive_package
    create_archive_package(recid)


@option_recid
예제 #7
0
## along with CDS. If not, see <http://www.gnu.org/licenses/>.
##
## In applying this licence, CERN does not waive the privileges and immunities
## granted to it by virtue of its status as an Intergovernmental Organization
## or submit itself to any jurisdiction.
"""Perform CDS demosite operations."""

from __future__ import print_function

import os
import pkg_resources
import sys

from invenio.ext.script import Manager

manager = Manager(usage=__doc__)

option_yes_i_know = manager.option('--yes-i-know',
                                   action='store_true',
                                   dest='yes_i_know',
                                   help='use with care!')


@option_yes_i_know
def populate(yes_i_know=False):
    """Load CDS general demorecords."""
    from invenio.utils.text import wrap_text_in_a_box, wait_for_user
    from invenio.config import CFG_PREFIX
    from invenio.modules.scheduler.models import SchTASK

    wait_for_user(
예제 #8
0
# 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.

"""Perform BibRecord operations."""

from invenio.ext.script import Manager

manager = Manager(usage=__doc__)

# 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.modules.formatter.models import Bibfmt
    from invenio.base.scripts.cache import reset_rec_cache
    from invenio.legacy.search_engine import get_record
    from invenio.ext.sqlalchemy import db
예제 #9
0
respectively. It creates backup of each output format with name
``<FORMAT>_legacy.bfo`` and generates new Jinja2 templates in
``CFG_BIBFORMAT_JINJA_TEMPLATE_PATH``.
"""

from __future__ import print_function

import os
import re
import shutil

from six import iteritems

from invenio.ext.script import Manager

manager = Manager(usage="Perform template 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):
예제 #10
0
import ast
import imp
import sys
import errno

from pprint import pformat
from flask import current_app
from invenio.ext.script import Manager, change_command_name, \
    generate_secret_key

try:
    from StringIO import StringIO
except ImportError:
    from io import StringIO

manager = Manager(usage="Perform configuration operations")


def default_keys():
    """Yield list of default configuration keys."""
    yield 'SECRET_KEY'
    for k in current_app.config.keys():
        if k.startswith('CFG_DATABASE'):
            yield k


def get_instance_config_object(filename='invenio.cfg', silent=True):
    """Get the configuration object from the given filename."""
    d = imp.new_module('config')
    d.__file__ = filename
    try:
예제 #11
0
# 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 __future__ import print_function

import os
import socket

from invenio.ext.script import Manager, change_command_name

manager = Manager(usage="Perform Apache operations.")


def _detect_ip_address():
    """Detect IP address of this computer.

    Useful for creating Apache vhost conf snippet on RHEL like machines.
    However, if wanted site is 0.0.0.0, then use that, since we are running
    inside Docker.

    :return: IP address, or '*' if cannot detect
    :rtype: string

    .. note:: creates socket for real in order to detect real IP address,
              not the loopback one.
    """
예제 #12
0
파일: manage.py 프로젝트: IviDim/cds
##
## In applying this licence, CERN does not waive the privileges and immunities
## granted to it by virtue of its status as an Intergovernmental Organization
## or submit itself to any jurisdiction.

"""Perform CDS demosite operations."""

from __future__ import print_function

import os
import pkg_resources
import sys

from invenio.ext.script import Manager

manager = Manager(usage=__doc__)

option_yes_i_know = manager.option('--yes-i-know', action='store_true',
                                   dest='yes_i_know', help='use with care!')


@option_yes_i_know
def photos(yes_i_know=False):
    """Load CDS photo demorecords."""
    _make_upload('cds-photos.xml', 'Going to load demo photos.')


@option_yes_i_know
def populate(yes_i_know=False):
    """Load CDS general demorecords."""
    _make_upload('cds-demobibdata.xml')
예제 #13
0
# 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.
"""Perform BibRecord operations."""

from invenio.ext.script import Manager

manager = Manager(usage=__doc__)

# 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.modules.formatter.models import Bibfmt
    from invenio.base.scripts.cache import reset_rec_cache
    from invenio.legacy.search_engine import get_record
    from invenio.ext.sqlalchemy import db
예제 #14
0
from __future__ import print_function

import argparse
import sys

from flask import current_app

from invenio.ext.script import Manager

import six

from werkzeug.utils import import_string

from .api import (start as start_workflow, start_delayed)

manager = Manager(description=__doc__)


def split_marcxml(source):
    """Split a MARCXML file using dojson MARC21 utils."""
    from dojson.contrib.marc21.utils import split_blob
    return [data for data in split_blob(source.read())]


@manager.option('name', help="Name of workflow to start.")
@manager.option('-i',
                '--input',
                type=argparse.FileType('r'),
                default=sys.stdin,
                help="Input file (defaults to STDIN).",
                dest='source')
예제 #15
0
# 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.
"""Perform record archiving operations."""

from invenio.ext.script import Manager

manager = Manager(usage=__doc__)

option_recid = manager.option("recid",
                              metavar='RECID',
                              type=int,
                              help="Record identifier")
option_version = manager.option("--version",
                                dest="version",
                                type=int,
                                default=-1,
                                help="Version or archived record.")


@option_recid
def create(recid):
    """Create an archive of record."""
예제 #16
0
from itertools import count

import pkg_resources

from invenio.base.utils import run_py_func
from invenio.ext.script import Manager


warnings.warn("Use of `inveniomanage demosite populate` is being deprecated. "
              "Please use `uploader` module to insert demo records.",
              PendingDeprecationWarning)




manager = Manager(usage=__doc__)

# 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_file = manager.option('-f', '--file', dest='files',
                             action='append', help='data file to use')
option_jobid = manager.option('-j', '--job-id', dest='job_id', type=int,
                              default=0, help='bibsched starting job id')
option_extrainfo = manager.option('-e', '--extra-info', dest='extra_info',
                                  action='append',
                                  help='extraneous parameters')
예제 #17
0
#
# 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 __future__ import print_function

from flask import current_app
from invenio.ext.script 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:
        from six.moves import cPickle as pickle
    except:
        import pickle
    from itertools import islice
    from intbitset import intbitset
예제 #18
0
파일: manage.py 프로젝트: mhellmic/b2share
## 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.ext.script import Manager

manager = Manager(usage="Perform upgrade engine operations.")


@manager.command
def run():
    """
    Command for applying upgrades
    """
    from invenio.modules.upgrader.commands import cmd_upgrade
    cmd_upgrade()


@manager.command
def check():
    """
    Command for checking upgrades
예제 #19
0
# 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.ext.script import Manager

manager = Manager(usage="Perform upgrade engine operations.")


@manager.command
def run():
    """
    Command for applying upgrades
    """
    from invenio_upgrader.commands import cmd_upgrade
    cmd_upgrade()


@manager.command
def check():
    """
    Command for checking upgrades
예제 #20
0
#
# 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.

"""Database script functions."""

from __future__ import print_function

import datetime

from flask import current_app

from invenio.ext.script import Manager, change_command_name, print_progress

manager = Manager(usage="Perform database 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_quiet = manager.option('--quiet', action='store_true',
                              dest='quiet', help='show less output')
option_default_data = manager.option(
    '--no-data', action='store_false',
    dest='default_data',
    help='do not populate tables with default data'
)


@manager.option('-u', '--user', dest='user', default="root")
@manager.option('-p', '--password', dest='password', default="")
예제 #21
0
#
# 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.

"""Perform output format migration operation."""

from __future__ import print_function

import os
import yaml

from flask import current_app
from invenio.ext.script import Manager

manager = Manager(usage="Perform output format migration operations.")


def get_output_format(filename):
    output_format = {'rules': [], 'default': ""}

    format_file = open(filename)

    current_tag = ''
    for line in format_file:
        line = line.strip()
        if line == "":
            # Ignore blank lines
            continue
        if line.endswith(":"):
            # Retrieve tag
예제 #22
0
# 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.
"""Perform operations with bibliographic records."""

from __future__ import print_function

import argparse
import json
import sys

from invenio.ext.script import Manager

manager = Manager(usage=__doc__)


def convert_marcxml(source):
    """Convert MARC XML to JSON."""
    from dojson.contrib.marc21 import marc21
    from dojson.contrib.marc21.utils import create_record, split_blob

    for data in split_blob(source.read()):
        yield marc21.do(create_record(data))


@manager.option('source',
                type=argparse.FileType('r'),
                default=sys.stdin,
                help="Input file.",
예제 #23
0
#
# 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 __future__ import print_function

__revision__ = "$Id$"

import subprocess
import sys

from invenio_base.globals import cfg
from invenio.ext.script import Manager

manager = Manager(usage="Runs SQL commands")


@manager.option('-V', '--version', dest='version', action='store_true',
                default=False,  help="Print version information.")
@manager.option('-i', '--interactive', dest='interactive', action='store_true',
                default=False, help="Bring inteactive SQL REPL. (default=batch-execute)")
def dbexec(version=False, interactive=False):
    """Runs SQL commands."""
    MYSQL = cfg.get('MYSQL', 'mysql')
    ## is version called?
    if version:
        print(__revision__)
        return 0

    params = [
예제 #24
0
파일: config.py 프로젝트: SCOAP3/invenio
import os.path
import sys

from pprint import pformat

from flask import current_app

from invenio.ext.script import Manager, change_command_name, \
    generate_secret_key

try:
    from StringIO import StringIO
except ImportError:
    from io import StringIO

manager = Manager(usage="Perform configuration operations")


def default_keys():
    """Yield list of default configuration keys."""
    yield 'SECRET_KEY'
    for k in current_app.config.keys():
        if k.startswith('CFG_DATABASE'):
            yield k


def get_instance_config_object(filename='invenio.cfg', silent=True):
    """Get the configuration object from the given filename."""
    d = imp.new_module('config')
    d.__file__ = filename
    try:
예제 #25
0
# as an Intergovernmental Organization or submit itself to any jurisdiction.
"""Manage checker module."""

import sys

from functools import wraps

from .common import ALL
from .recids import ids_from_input
from .registry import plugin_files
from .models import CheckerRule, CheckerRecord
from invenio.base.factory import create_app
from invenio.ext.script import Manager, change_command_name
from invenio.ext.sqlalchemy import db

manager = Manager(usage=__doc__)
rules_dec = manager.option('--rules',
                           '-r',
                           default=ALL,
                           help='Comma seperated list of rule names to load,'
                           ' or `{}` for all rules.'.format(ALL))


def interpret_dry_run(func):
    """Resolve `dry_run` to variables understood by `run()`."""
    @wraps(func)
    def _dry_run(*args, **kwargs):
        if 'dry_run' in kwargs:
            if kwargs['dry_run']:
                kwargs['upload'] = False
                kwargs['tickets'] = False