当前位置: 首页>>代码示例>>Python>>正文


Python Project.get_by_name方法代码示例

本文整理汇总了Python中models.project.Project.get_by_name方法的典型用法代码示例。如果您正苦于以下问题:Python Project.get_by_name方法的具体用法?Python Project.get_by_name怎么用?Python Project.get_by_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.project.Project的用法示例。


在下文中一共展示了Project.get_by_name方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_project_env

# 需要导入模块: from models.project import Project [as 别名]
# 或者: from models.project.Project import get_by_name [as 别名]
def set_project_env():
    form = request.form
    project = form['project']
    env = form['env']
    content = {}

    p = Project.get_by_name(project)
    if not p.is_accessible(g.user):
        return {'reason': '你没有操作这个项目的权限'}, 403

    for line, i in enumerate(form['content'].split('\n')):
        if not i.strip():
            continue

        kv = i.split('=', 1)
        if len(kv) == 1:
            raise ValueError('invalid env item %s at line %d' % (i, line + 1))

        content[kv[0].strip()] = kv[1].strip()

    try:
        eru.set_app_env(project, env, **content)
    except Exception as e:
        print e.message
    log = OPLog.create(g.user.id, OPLOG_ACTION.set_project_env)
    log.data = content
    log.project_name = project
开发者ID:tonicbupt,项目名称:ainur,代码行数:29,代码来源:deploy.py

示例2: deploy_container_api

# 需要导入模块: from models.project import Project [as 别名]
# 或者: from models.project.Project import get_by_name [as 别名]
def deploy_container_api():
    form = request.form
    project = form['project']
    if project == APPNAME_ERU_LB:
        raise ValueError('Unable to deploy eru-lb, do it on load balance page')

    p = Project.get_by_name(project)
    if not p.is_accessible(g.user):
        return {'reason': '你没有操作这个项目的权限'}, 403

    version = form['version']

    eru.deploy_private(
        group_name=g.user.group,
        pod_name=form['pod'],
        app_name=project,
        ncore=form.get('ncore', type=float),
        ncontainer=form.get('ncontainer', type=int),
        version=version,
        entrypoint=form['entrypoint'],
        env=form['env'],
        network_ids=form.getlist('network'),
        host_name=form.get('host'),
        args=form['extendargs'].split(' '),
    )

    log = OPLog.create(g.user.id, OPLOG_ACTION.create_container)
    log.project_name = project
    log.image = '%s:%s' % (project, version)
开发者ID:tonicbupt,项目名称:ainur,代码行数:31,代码来源:deploy.py

示例3: delete_project_env

# 需要导入模块: from models.project import Project [as 别名]
# 或者: from models.project.Project import get_by_name [as 别名]
def delete_project_env():
    name = request.form['project']
    p = Project.get_by_name(name)
    if not p.is_accessible(g.user):
        return {'reason': '你没有操作这个项目的权限'}, 403

    eru.delete_app_env(name, request.form['env'])
    return {'msg': 'ok'}
开发者ID:tonicbupt,项目名称:ainur,代码行数:10,代码来源:deploy.py

示例4: build_image

# 需要导入模块: from models.project import Project [as 别名]
# 或者: from models.project.Project import get_by_name [as 别名]
def build_image(name):
    project = Project.get_by_name(name)
    if not project:
        abort(404)

    revisions = _get_project_commits(project.git)
    pods = eru.list_group_pods(g.user.group)
    base_images = BaseImage.list_all()
    return render_template(
        '/deploy/projects/build_image.html', project=project,
        revisions=revisions, pods=pods, base_images=base_images)
开发者ID:tonicbupt,项目名称:ainur,代码行数:13,代码来源:deploy.py

示例5: start_container

# 需要导入模块: from models.project import Project [as 别名]
# 或者: from models.project.Project import get_by_name [as 别名]
def start_container():
    cid = request.form['id']
    name = eru.get_container(cid)['appname']

    p = Project.get_by_name(name)
    if not p.is_accessible(g.user):
        return {'reason': '你没有操作这个项目的权限'}, 403

    eru.start_container(cid)

    log = OPLog.create(g.user.id, OPLOG_ACTION.start_container)
    log.container_id = cid
开发者ID:tonicbupt,项目名称:ainur,代码行数:14,代码来源:deploy.py

示例6: stop_container

# 需要导入模块: from models.project import Project [as 别名]
# 或者: from models.project.Project import get_by_name [as 别名]
def stop_container():
    cid = request.form['id']
    name = eru.get_container(cid)['appname']
    if name == APPNAME_ERU_LB:
        raise ValueError('Unable to stop eru-lb, do it on load balance page')

    p = Project.get_by_name(name)
    if not p.is_accessible(g.user):
        return {'reason': '你没有操作这个项目的权限'}, 403

    eru.stop_container(cid)
    log = OPLog.create(g.user.id, OPLOG_ACTION.stop_container)
    log.container_id = cid
开发者ID:tonicbupt,项目名称:ainur,代码行数:15,代码来源:deploy.py

示例7: grant_project

# 需要导入模块: from models.project import Project [as 别名]
# 或者: from models.project.Project import get_by_name [as 别名]
def grant_project(uid):
    user = User.get_by_uid(uid)
    if not user:
        return {'reason': '用户不存在'}, 404

    name = request.form.get('project', '')
    p = Project.get_by_name(name)
    if not p:
        return {'reason': '项目不存在'}, 404

    user.grant_project(name)
    log = OPLog.create(g.user.id, OPLOG_ACTION.grant_project)
    log.project_name = name
    log.acceptor = user.uid
开发者ID:tonicbupt,项目名称:ainur,代码行数:16,代码来源:settings.py

示例8: api_build_image

# 需要导入模块: from models.project import Project [as 别名]
# 或者: from models.project.Project import get_by_name [as 别名]
def api_build_image():
    name = request.form['project']
    app = eru.get_app(name)

    p = Project.get_by_name(name)
    if not p.is_accessible(g.user):
        return {'reason': '你没有操作这个项目的权限'}, 403

    revision = request.form['revision']
    _register_app(app['git'], revision)
    _get_project(app['git'])

    pod = request.form['pod']
    image = 'docker-registry.intra.hunantv.com/nbeimage/%s' % request.form['image']
    eru.build_image(g.user.group, pod, app['name'], image, revision)

    log = OPLog.create(g.user.id, OPLOG_ACTION.build_image)
    log.project_name = name
    log.image = '%s:%s' % (name, revision)
开发者ID:tonicbupt,项目名称:ainur,代码行数:21,代码来源:deploy.py

示例9: detail

# 需要导入模块: from models.project import Project [as 别名]
# 或者: from models.project.Project import get_by_name [as 别名]
def detail(name):
    project = Project.get_by_name(name)
    if not project:
        abort(404)
    return render_template('/deploy/projects/detail.html', project=project)
开发者ID:tonicbupt,项目名称:ainur,代码行数:7,代码来源:deploy.py


注:本文中的models.project.Project.get_by_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。