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


Python MarathonClient.create_app_by_json方法代码示例

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


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

示例1: new_app

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import create_app_by_json [as 别名]
def new_app(request):
    data = {}
    if request.method == "POST":
        data["msg"] = "Post"
        post_params = {}
        for key in request.POST:
            if key.startswith("filehidden"):
                fkey = key[11:]
                if request.FILES.get(fkey, None):
                    post_file = request.FILES[fkey]
                    file_content = ""
                    for chunk in post_file.chunks():
                        file_content += chunk.decode("utf8")
                    post_params[fkey] = convert(file_content)
                else:
                    post_params[fkey] = request.POST[key]
            else:
                post_params[key] = request.POST[key]

        template = Template.objects.get(pk=post_params["template_id"])
        content = template.content % post_params
        data["content"] = content
        mc = MarathonClient("http://{}:{}".format(settings.MARATHON["host"], settings.MARATHON["port"]))
        try:
            mc.create_app_by_json(content)
            data["result"] = "Success"
        except Exception as e:
            data["result"] = str(e)

    templates = Template.objects.filter(type="marathon").all()
    for template in templates:
        template.params = template.param_set.order_by("id")

    data["templates"] = templates
    return render(request, "marathon_mgmt/new_app.html", data)
开发者ID:ntk148v,项目名称:mesos-admin,代码行数:37,代码来源:views.py

示例2: new_app

# 需要导入模块: from marathon import MarathonClient [as 别名]
# 或者: from marathon.MarathonClient import create_app_by_json [as 别名]
def new_app(request, type):
    data = {}
    if request.method == 'POST':
        data['msg'] = "Post"
        post_params = {}
        for key in request.POST:
            if key.startswith("filehidden"):
                fkey = key[11:]
                if(request.FILES.get(fkey, None)):
                    post_file = request.FILES[fkey]
                    file_content=""
                    for chunk in post_file.chunks():
                        file_content += chunk.decode("utf8")
                    post_params[fkey] = convert(file_content)
                else:
                    post_params[fkey] = request.POST[key]
            else:
                post_params[key] = request.POST[key]


        template = Template.objects.get(pk=post_params['template_id'])
        content = template.content%post_params
        data['content'] = content
        mc = MarathonClient('http://{}:{}'.format(settings.MARATHON['host'], settings.MARATHON['port']))
        try:
            if(type == "app"):
                mc.create_app_by_json(content)
            elif(type == "group"):
                mc.create_group(content)
            data['result'] = "Success"
        except Exception as e:
            data['result'] = str(e)

    if(type == "app"):
        data['type'] = "Application"
        templates = Template.objects.filter(type="marathon-app").order_by('name').all()
    elif(type == "group"):
        data['type'] = "Group"
        templates = Template.objects.filter(type="marathon-group").order_by('name').all()
    for template in templates:
        template.params = template.param_set.order_by('id')

    data['templates'] = templates
    return render(request, 'marathon_mgmt/new_app.html', data)
开发者ID:huanpc,项目名称:mesos-admin,代码行数:46,代码来源:views.py


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