예제 #1
0
def import_item(args):
    ia_id = args[0]
    item = ImportItem.find_by_identifier(ia_id)
    if item:
        do_import(item)
    else:
        logger.error("%s is not found in the import queue", ia_id)
예제 #2
0
def import_ocaids(*ocaids, **kwargs):
    """This method is mostly for testing. It allows you to import one more
    archive.org items into Open Library by ocaid

    Usage:
        $ sudo -u openlibrary /olsystem/bin/olenv \
            HOME=/home/openlibrary OPENLIBRARY_RCFILE=/olsystem/etc/olrc-importbot \
            python scripts/manage-imports.py \
                --config /olsystem/etc/openlibrary.yml \
                import-all
    """
    servername = kwargs.get('servername', None)
    require_marc = not kwargs.get('no_marc', False)

    date = datetime.date.today()
    if not ocaids:
        raise ValueError("Must provide at least one ocaid")
    batch_name = "import-%s-%04d%02d" % (ocaids[0], date.year, date.month)
    try:
        batch = Batch.new(batch_name)
    except Exception as e:
        logger.info(str(e))
    try:
        batch.add_items(ocaids)
    except Exception:
        logger.info("skipping batch adding, already present")

    for ocaid in ocaids:
        item = ImportItem.find_by_identifier(ocaid)
        if item:
            do_import(item, servername=servername, require_marc=require_marc)
        else:
            logger.error("%s is not found in the import queue", ia_id)
예제 #3
0
def import_item(args):
    ia_id = args[0]
    item = ImportItem.find_by_identifier(ia_id)
    if item:
        do_import(item)
    else:
        logger.error("%s is not found in the import queue", ia_id)
예제 #4
0
def import_item(args, **kwargs):
    servername = kwargs.get('servername', None)
    ia_id = args[0]
    item = ImportItem.find_by_identifier(ia_id)
    if item:
        do_import(item, servername=servername)
    else:
        logger.error("%s is not found in the import queue", ia_id)
예제 #5
0
def import_all(args):
    while True:
        items = ImportItem.find_pending()
        if not items:
            logger.info("No pending items found. sleeping for a minute.")
            time.sleep(60)

        for item in items:
            do_import(item)
예제 #6
0
def import_all(args):
    while True:
        items = ImportItem.find_pending()
        if not items:
            logger.info("No pending items found. sleeping for a minute.")
            time.sleep(60)

        for item in items:
            do_import(item)
예제 #7
0
def import_item(args, **kwargs):
    servername = kwargs.get('servername', None)
    require_marc = not kwargs.get('no_marc', False)
    ia_id = args[0]
    item = ImportItem.find_by_identifier(ia_id)
    if item:
        do_import(item, servername=servername, require_marc=require_marc)
    else:
        logger.error(f"{ia_id} is not found in the import queue")
예제 #8
0
def import_all(args, **kwargs):
    servername = kwargs.get('servername', None)
    while True:
        items = ImportItem.find_pending()
        if not items:
            logger.info("No pending items found. sleeping for a minute.")
            time.sleep(60)

        for item in items:
            do_import(item, servername=servername)
예제 #9
0
def import_all(args, **kwargs):
    servername = kwargs.get('servername')
    require_marc = not kwargs.get('no_marc', False)
    while True:
        items = ImportItem.find_pending()
        if not items:
            logger.info("No pending items found. sleeping for a minute.")
            time.sleep(60)

        for item in items:
            do_import(item, servername=servername, require_marc=require_marc)