stop.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:valohai-cli 作者: valohai 项目源码 文件源码
def stop(counters, all=False):
    """
    Stop one or more in-progress executions.
    """
    project = get_project(require=True)
    params = {'project': project.id}
    if counters and all:
        raise click.UsageError('Pass either an execution # or `--all`, not both.')
    elif counters:
        params['counter'] = sorted(IntegerRange.parse(counters).as_set())
    elif all:
        params['status'] = 'incomplete'
    else:
        warn('Nothing to stop (pass #s or `--all`)')
        return 1

    for execution in request('get', '/api/v0/executions/', params=params).json()['results']:
        click.echo('Stopping #{counter}... '.format(counter=execution['counter']), nl=False)
        resp = request('post', execution['urls']['stop'])
        click.echo(resp.text)
    success('Done.')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号