Beispiel #1
0
    def _init_directoy(self, branch):
        """
        初始化项目
        git fetch --all
        git reset --hard origin/zjsuperd
        :return:
        """
        try:
            log.debug('重置本地为远端git库:开始')
            try:
                cmd = [
                    'git fetch --all',
                    'git reset --hard origin/{}'.format(branch),
                    'git checkout . && git clean -xdf', 'git status'
                ]
                for c in cmd:
                    log.debug('初始化项目:{}'.format(c))
                    executionShell(c, self.project_path, 50)
                # res = self.repo.git.checkout('.')
                # log.debug('checkout:{}'.format(res))
                # res = self.repo.git.clean('-df')
                # log.debug('clean:{}'.format(res))
                # self.pull()
                # log.debug('重置本地为远端git库:完成')
                # res = self.git.log('-1')
                # log.debug('最近一次更新:\n{}'.format(res))

            except Exception as e:
                log.error(e)
            self.change_branch(branch)
        except Exception as e:
            log.error(e)
Beispiel #2
0
    def tag_info(self, request):
        auth = at.auth(request)
        if auth == 200:
            try:
                tag_sw = str(request.GET.get('tag'))
                tag = tag_sw.split('_')[0]
                sw = tag_sw.split('_')[1]
                if tag:

                    path, branch = getProjeck_path(sw)
                    log.debug('sw:{},pj_path:{},tag:{}'.format(sw, path, tag))
                    if tag == 'RC':
                        cmd = 'git log -n1'
                    else:
                        cmd = "git show {}".format(tag)
                    data = executionShell(cmd, path)
                    adata = []
                    for i in data:
                        if len(i) > 1:
                            i = str(i).replace('<', '').replace('>', '')
                            adata.append(i)
                    return JsonResponse(adata)
            except Exception as e:
                log.error(e)
                return JsonError(str(e))
        return auth
Beispiel #3
0
 def restart(self, request):
     try:
         c_key = request.GET.get('token')
         cmd = request.GET.get('cmd')
         if '32d8358abcdc9be57a267a9b1bb45ad0' == c_key:
             if not cmd:
                 cmd = 'restart'
             cmd = 'sh restart.sh {}'.format(cmd)
             cwd = '/home/zjzy/build/'
             log.debug('cmd:{},cwd:{}'.format(cmd, cwd))
             executionShell(cmd, cwd)
             HttpResponseRedirect('/public')
             return JsonResponse(1)
         return JsonError('auth error')
     except Exception as e:
         return JsonError(str(e))
Beispiel #4
0
    def delTag(self, tag, sw):
        cmd_r = 'git push origin :refs/tags/{}'.format(tag)
        cmd_l = 'git tag -d {}'.format(tag)
        rdata = []
        for cmd in [cmd_r, cmd_l]:
            data = executionShell(cmd, self.project_path)
            rdata.append(data)
        Operatingtag.objects.filter(project_name=sw, tag=tag).update(status=0)

        return rdata
Beispiel #5
0
    def build(self, map_dev_model, dev_model, user, tag, reason, type):
        # map_dev_model 是映射的型号名称,即cbuild文件中的型号名称,这个型号名称有的是型号名称本身,有的是编译链简称,有的是型号名称小写
        status = 400
        try:
            cmd = './cbuild.sh {}>{}_out.log 2>&1'.format(
                map_dev_model, dev_model)
            build_shell_path = proxy_client_build_shell_path

            log.debug('构建{}:{},路径:{}'.format(type, cmd, build_shell_path))
            build_data = executionShell(cmd, build_shell_path, 1)
            # status = self.is_ok(dev_model)
            # if not build_data:
            #     build_data ='400'
            self.record_build_log(dev_model, str(user), build_data, tag,
                                  reason, status, type)
        except Exception as e:
            log.error(e)
        return status