示例#1
0
文件: views.py 项目: zeus911/eva
def conf_edit(request,uuid):
    data = Confile.objects.get(pk=uuid)
    cf = ConfileFrom(instance=data)
    if request.method == 'POST':
        cf = ConfileFrom(request.POST,instance=data)
        if cf.is_valid():
            cf_data = cf.save()
            return HttpResponseRedirect('/success/')

    return render(request,'automation/conf_edit.html',locals())
示例#2
0
文件: views.py 项目: zeus911/eva
def conf_add(request):
    """实现添加发布的基本参数配置,但提交的时候会到指定的目录下面clone仓库"""
    cf = ConfileFrom()
    cf_errors = []
    name = request.POST.get('name', '')
    path = request.POST.get('localhost_dir', '')
    tool = request.POST.get('tool', '')
    if tool:
        tool = Tools.objects.get(uuid=tool)
        url = tool.address
    ifile = path + '.git/config'


    if Confile.objects.filter(name=name):
        cf_errors.append(u"所填标题已存在")
    # if Confile.objects.filter(localhost_dir=path):
    #     cf_errors.append(u"所填仓库路径已存在")


    if request.method == 'POST':
        cf = ConfileFrom(request.POST)
        if os.path.isfile(ifile):
            if check_file(ifile,url):
                pass
            else:
                cf_errors.append(u"所填仓库路径已存在,并且里面已经有git文件")
        if cf.is_valid():
            if not cf_errors:
                cf_data = cf.save()            ##保存信息后先判断repo的clone路径存不存在,不存在则创建
                if os.path.isdir(path):
                    pass
                else:
                    os.makedirs(path)
                repo = Repo(path)
                repo.git_clone(url,path)
                return HttpResponseRedirect('/deploy/conf_list/')

    return render(request,'automation/conf_add.html',locals())
示例#3
0
文件: views.py 项目: zeus911/eva
def conf_detail(request,uuid):
    data = Confile.objects.get(pk=uuid)
    if data:
        cf = ConfileFrom(instance=data)
    return render(request,'automation/conf_detail.html',locals())
示例#4
0
文件: views.py 项目: zeus911/eva
def conf_add_svn(request):
    """实现添加发布的基本参数配置,但提交的时候会到指定的目录下面clone仓库"""
    cf = ConfileFrom()
    cf_errors = []
    name = request.POST.get('name', '')

    path = request.POST.get('localhost_dir', '')
    path_two = request.POST.get('localhost_dir_two', '')
    path_three = request.POST.get('localhost_dir_three', '')

    tool_tail = request.POST.get('tool_tail', '')
    tool_tail_two = request.POST.get('tool_tail_two', '')
    tool_tail_three = request.POST.get('tool_tail_three', '')


    svn_options = Tools.objects.filter(name='Subversion')

    if Confile.objects.filter(name=name):
        cf_errors.append(u"所填标题已存在")
    if Confile.objects.filter(localhost_dir=path):
        cf_errors.append(u"所填主库checkout目录已存在")


    if request.method == 'POST':
        cf = ConfileFrom(request.POST)
        tool_uuid = request.POST.get('tool', '')
        data = Tools.objects.get(pk=tool_uuid)
        svn_url = data.address + tool_tail

        tool_uuid_two = request.POST.get('tool_two', '')
        svn_url_two = None
        if tool_uuid_two:
            data_two = Tools.objects.get(pk=tool_uuid_two)
            svn_url_two = data_two.address + tool_tail_two
        if svn_url_two:
            if not path_two:
                cf_errors.append(u"没有给出副库checkout的目录")

        tool_uuid_three = request.POST.get('tool_three', '')
        svn_url_three = None
        if tool_uuid_three:
            data_three = Tools.objects.get(pk=tool_uuid_three)
            svn_url_three = data_three.address + tool_tail_three
        if svn_url_three:
            if not path_three:
                cf_errors.append(u"没有给出叁库checkout的目录")

        if cf.is_valid():
            if not cf_errors:
                cf_data = cf.save()            ##保存信息
                if svn_url:
                    user = data.user
                    password = data.passwd
                    if os.path.isdir(path):
                        pass
                    else:
                        os.makedirs(path)
                    job = svn_checkout_task.delay(user,password,svn_url,path,"--no-auth-cache")
                    # repo = Svnrepo(path)               ## checkout第一个库
                    # repo.svn_checkout(user,password,svn_url,path,"--no-auth-cache")

                if svn_url_two:
                    user_two = data_two.user
                    password_two = data_two.passwd
                    if os.path.isdir(path_two):
                        pass
                    else:
                        os.makedirs(path_two)
                    job = svn_checkout_task.delay(user_two,password_two,svn_url_two,path_two,"--no-auth-cache")
                    # repo_two = Svnrepo(path_two)
                    # repo.svn_checkout(user_two,password_two,svn_url_two,path_two,"--no-auth-cache")

                if svn_url_three:
                    user_three = data_three.user
                    password_three = data_three.passwd
                    if os.path.isdir(path_three):
                        pass
                    else:
                        os.makedirs(path_three)
                    job = svn_checkout_task.delay(user_three,password_three,svn_url_three,path_three,"--no-auth-cache")
                    # repo_three = Svnrepo(path_three)
                    # repo.svn_checkout(user_three,password_three,svn_url_three,path_three,"--no-auth-cache")


            return HttpResponseRedirect('/deploy/conf_list/')

    # return HttpResponse("success")
    return render(request,'automation/conf_add_svn.html',locals())