Example #1
0
    updater.main(image, ctx.obj['dry_run'], ctx.obj['verbose'], list(path))


@cli.command(name='latest-ami', help=AMIUpdater.__doc__)
@click.option('--ami-name-pattern', required=True, help='glob style pattern of the AMI image name to use')
@click.option('--add-new-version', is_flag=True, default=False, help='of the AMI resource and replace all references')
@click.argument('path', nargs=-1, required=True, type=click.Path(exists=True))
@click.pass_context
def ami_image_update(ctx, ami_name_pattern, add_new_version, path):
    updater = AMIUpdater()
    updater.main(ami_name_pattern, ctx.obj['dry_run'], ctx.obj['verbose'], add_new_version, list(path))


@cli.command(name='cron-schedule-expression', help=CronScheduleExpressionUpdater.__doc__)
@click.option('--timezone', required=False, help='to use to calculate the UTC time', default="Europe/Amsterdam")
@click.option('--date', type=click_datetime.Datetime(format='%Y-%m-%d'), default=datetime.now(),
              help='to use as reference date')
@click.argument('path', nargs=-1, required=True, type=click.Path(exists=True))
@click.pass_context
def cron_schedule_expression(ctx, timezone, date, path):
    updater = CronScheduleExpressionUpdater()
    try:
        tz = pytz.timezone(timezone)
        updater.main(tz, date, ctx.obj['dry_run'], ctx.obj['verbose'], list(path))
    except pytz.exceptions.UnknownTimeZoneError:
        raise click.BadParameter('invalid timezone specified', ctx=ctx, param='timezone')


@cli.command(name='rest-api-body', help=RestAPIBodyUpdater.__doc__)
@click.option('--resource', required=True, help='AWS::ApiGateway::RestApi body to update')
@click.option('--open-api-specification', required=True, type=click.Path(exists=True), help='defining the interface')
Example #2
0
import asyncio
import os
import os.path
import sys
from datetime import datetime

import asyncpg.exceptions
import click
import click_datetime
from alembic.command import upgrade
from alembic.config import Config

from puckdb import db, fetch, server

DATE_PARAM = click_datetime.Datetime(format='%Y-%m-%d')


def abort_if_false(ctx, _, value):
    if not value:
        ctx.abort()


def _setup():
    loop.run_until_complete(db.setup())


@click.command(help='Initialize the database')
def init():
    loc = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
    config = Config(os.path.join(loc, 'alembic.ini'))
    upgrade(config, 'head')
Example #3
0
    if roi or all_info:
        click.echo('\n######################### ROIS #########################')
        click.echo(vds.rois)
        click.echo()
        vds.logger.info(' ================== Finished ==================')


@api.command(short_help='Download gridded data over a range of dates')
@click.option('--config_file', '-c', type=click.Path(exists=True),
              help='Path to configuration file (optional)')
@click.option('--product', '-p', 'products', required=True, multiple=True,
              help='Product to download (call multiple by repeating -p)')
@click.option('--lon_range', '-lo', nargs=2, required=True, type=float, help='Range of longitudes:   min max')
@click.option('--lat_range', '-la', nargs=2, required=True, type=float, help='Range of latitudes:    min max')
@click.option('--date_range', '-dr', nargs=2, type=click_dt.Datetime(format='%Y-%m-%d'),
              help='Start end date for daterange:\nYYYY-MM-DD YYYY-MM-DD')
@click.option('--format', '-f', 'fmt', type=click.Choice(['gtiff', 'netcdf4']), help='File format, default is gtiff')
@click.option('--n_proc', '-n', default=4, type=click.IntRange(1, 8), help='Number of simultaneous calls to the API', show_default=True)
@click.option('--outfold', '-o', help='Path to output the data (created if non-existent)')
@click.option('--zipped', '-z', is_flag=True, default=False, help='Return zip folders with all files included')
@click.option('--verbose/--no-verbose', '-v', default=False, help='Set debug statements on')
@click.pass_context
def grid(ctx, config_file, products, lon_range, lat_range, date_range,
         fmt, n_proc, outfold, zipped, verbose):

    vds = VdsApiV2(ctx.obj['user'], ctx.obj['passwd'], debug=False)
    if ctx.obj['environment'] is not None:
        vds.host = ctx.obj['environment']
    if ctx.obj['impersonate']:
        vds.impersonate(ctx.obj['impersonate'])
Example #4
0
@click.argument('title')
@click.argument('description')
@click.option('--username')
@click.option('--in-progress', is_flag=True)
@click.option('--assign', is_flag=True)
@click.option('--importance',
              prompt=True,
              type=click.Choice(['Low', 'Medium', 'High'],
                                case_sensitive=False))
@click.option('--effort',
              prompt='Level of Effort',
              type=click.Choice(['Low', 'Medium', 'High'],
                                case_sensitive=False))
@click.option('--due',
              prompt='Due date (mm/dd/yyyy)',
              type=click_datetime.Datetime(format='%m/%d/%Y'))
def create(title, description, username, in_progress, assign, importance,
           effort, due):
    cli_library.echo('Adding EL task {}; {}'.format(title, description))

    auth = ComboAuth(username)

    new_task = ElTask.from_args(title, description, in_progress, assign,
                                importance, effort, due, auth)
    try:
        task_id, url = new_task.create()
        cli_library.echo('EL task {} added at {}'.format(task_id, url))
        if in_progress:
            cli_library.echo('EL task put into In Progress')
    except HTTPError as exception:
        cli_library.fail_execution(
Example #5
0
                ' (SequenceID, CodonPos, AA, NA) VALUES'
                " (@sequence_id, {pos}, '{aas}', '{nas}');\n".format(**ins))

    # enter tblMixtures
    for mix in mixtures:
        sql += ('INSERT INTO tblMixtures'
                ' (SequenceID, CodonPos, AA) VALUES'
                " (@sequence_id, {pos}, '{aas}');\n".format(**mix))

    return sql


@app.cli.command()
@click.option('--start-date',
              prompt=True,
              type=click_datetime.Datetime('%Y-%m-%d'))
@click.option('--stop-date',
              prompt=True,
              type=click_datetime.Datetime('%Y-%m-%d'))
@click.option('--ptnum', type=int)
@click.argument('output', type=click.File('w'))
def export2hivdb(start_date, stop_date, ptnum, output):
    required_ptnum = ptnum
    start = start_date.replace(tzinfo=CURRENT_TIMEZONE)
    stop = stop_date.replace(tzinfo=CURRENT_TIMEZONE)
    output.write(sql_create_temp_new_patients_table())
    filter_args = [
        models.Patient.visits.any(
            models.PatientVisit.samples.any(
                db.and_(
                    db.between(models.PatientSample.entered_at, start, stop),
Example #6
0
@click.argument('path', nargs=-1, required=True, type=click.Path(exists=True))
@click.pass_context
def ami_image_update(ctx, ami_name_pattern, add_new_version, path):
    updater = AMIUpdater()
    updater.main(ami_name_pattern, ctx.obj['dry_run'], ctx.obj['verbose'],
                 add_new_version, list(path))


@cli.command(name='cron-schedule-expression',
             help=CronScheduleExpressionUpdater.__doc__)
@click.option('--timezone',
              required=False,
              help='to use to calculate the UTC time',
              default="Europe/Amsterdam")
@click.option('--date',
              type=click_datetime.Datetime(format='%Y-%m-%d'),
              default=datetime.now(),
              help='to use as reference date')
@click.argument('path', nargs=-1, required=True, type=click.Path(exists=True))
@click.pass_context
def cron_schedule_expression(ctx, timezone, date, path):
    updater = CronScheduleExpressionUpdater()
    try:
        tz = pytz.timezone(timezone)
        updater.main(tz, date, ctx.obj['dry_run'], ctx.obj['verbose'],
                     list(path))
    except pytz.exceptions.UnknownTimeZoneError:
        raise click.BadParameter('invalid timezone specified',
                                 ctx=ctx,
                                 param='timezone')