コード例 #1
0
def show(ctx, id):
    """Shows a harvest source.
    """
    flask_app = ctx.meta["flask_app"]

    try:
        with flask_app.test_request_context():
            result = utils.show_harvest_source(id)
    except tk.ObjectNotFound as e:
        tk.error_shout(u"Source <{}> not found.".format(id))
        raise click.Abort()
    click.echo(result)
コード例 #2
0
def job(ctx, id):
    """Create new harvest job and runs it (puts it on the gather queue).

    """
    flask_app = ctx.meta["flask_app"]
    with flask_app.test_request_context():
        try:
            result = utils.create_job(id)
        except HarvestJobExists as e:
            tk.error_shout(e)
            ctx.abort()
    click.echo(result)
コード例 #3
0
def create(name, url, type, title, active, owner_org, frequency, config):
    """Create new harvest source.
    """
    try:
        result = utils.create_harvest_source(name, url, type, title, active,
                                             owner_org, frequency, config)
    except tk.ValidationError as e:
        tk.error_shout(u"Validation error:")
        for field, err in e.error_summary.items():
            tk.error_shout("\t{}: {}".format(field, err))
        raise click.Abort()
    click.echo(result)
コード例 #4
0
def job_abort(ctx, id):
    """Marks a job as "Aborted" so that the source can be restarted afresh.

    It ensures that the job's harvest objects status are also marked
    finished. You should ensure that neither the job nor its objects
    are currently in the gather/fetch queues.

    """
    flask_app = ctx.meta["flask_app"]
    with flask_app.test_request_context():
        try:
            result = utils.abort_job(id)
        except tk.ObjectNotFound as e:
            tk.error_shout(u"Job not found.")
            ctx.abort()

    click.echo(result)
コード例 #5
0
def import_stage(
    ctx, id, no_join_datasets, harvest_object_id, guid, package_id, segments
):
    """Perform the import stage with the last fetched objects, for a
    certain source or a single harvest object.

    Please note that no objects will be fetched from the remote
    server. It will only affect the objects already present in the
    database.

    To import a particular harvest source, specify its id as an argument.
    To import a particular harvest object use the -o option.
    To import a particular guid use the -g option.
    To import a particular package use the -p option.

    You will need to specify the -j flag in cases where the datasets
    are not yet created (e.g. first harvest, or all previous harvests
    have failed)

    The --segments flag allows to define a string containing hex
    digits that represent which of the 16 harvest object segments to
    import. e.g. 15af will run segments 1,5,a,f

    """
    ctx.invoke(initdb)
    flask_app = ctx.meta["flask_app"]
    with flask_app.test_request_context():
        try:
            utils.import_stage(
                id,
                no_join_datasets,
                harvest_object_id,
                guid,
                package_id,
                segments,
            )
        except tk.ObjectNotFound as e:
            tk.error_shout(u"Source <{}> not found.".format(id))