__main__.py 文件源码

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

项目:simphony-remote 作者: simphony 项目源码 文件源码
def create(ctx, image, verify):
    """Creates a new application for image IMAGE."""

    # Verify if `image` is an existing docker image
    # in this machine
    if verify:
        msg = ('{error}. You may consider skipping verifying '
               'image name against docker with --no-verify.')
        try:
            client = get_docker_client()
            client.inspect_image(image)
        except Exception as exception:
            raise click.BadParameter(msg.format(error=str(exception)),
                                     ctx=ctx)

    session = ctx.obj.session
    try:
        with orm.transaction(session):
            orm_app = orm.Application(image=image)
            session.add(orm_app)
    except sqlalchemy.exc.IntegrityError:
        print_error("Application for image {} already exists".format(image))
    else:
        print(orm_app.id)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号