def showList(request): group=request.GET.get("group") page=request.GET.get("page") data=utils.get_group_name(request) url=public.JAVA_HOST + "/onlinecard/api/online_cards?group="+group+"&pageNum="+page req = public.get_data(url) req_dict = json.loads(req) return render(request,'onlinecards_list.html',{"data":data,"group":req_dict,"group_id":long(group),"pageNum":long(page)})
def deadDetail(request): ''' 死链详情 :param request: :return: ''' id=request.GET.get("id") url=public.JAVA_HOST + "/deadlink/api/details?id="+id req = public.get_data(url) retdata=json.loads(req) return render(request,'deadDetail.html',{"data":retdata})
def deadDetail(request): ''' 死链详情 :param request: :return: ''' id = request.GET.get("id") url = public.JAVA_HOST + "/deadlink/api/details?id=" + id req = public.get_data(url) retdata = json.loads(req) return render(request, 'deadDetail.html', {"data": retdata})
def deadlist(request): ''' 死链列表 :param request: :return: ''' ret = {} page = request.GET.get("page") url = public.JAVA_HOST + "/deadlink/api/results?page=" + page req = public.get_data(url) compressedData = json.loads(req) if request.GET.get('page'): page = int(request.GET.get('page')) else: page = 1 if compressedData: if compressedData["size"] % 10 > 0: ret['last_page'] = compressedData["size"] / 10 + 1 else: ret['last_page'] = compressedData["size"] / 10 else: ret['last_page'] = 0 if ret['last_page'] <= 5: ret['pages'] = range(1, ret['last_page'] + 1) else: if page < 3: ret['pages'] = range(1, 6) else: if page + 3 <= ret['last_page']: ret['pages'] = range(page - 2, page + 3) elif page < ret['last_page']: if ret['last_page'] - 5 < page: ret['pages'] = range(ret['last_page'] - 4, ret['last_page'] + 1) else: ret['pages'] = range(page - 2, ret['last_page'] + 1) else: ret['pages'] = range(page - 4, page + 1) ret['page'] = page ret['pre'] = page - 1 if page == ret['last_page']: ret['next'] = -1 else: ret['next'] = page + 1 return render(request, 'deadList.html', { "data": compressedData['data'], "ret": ret })
def showList(request): group = request.GET.get("group") page = request.GET.get("page") data = utils.get_group_name(request) url = public.JAVA_HOST + "/onlinecard/api/online_cards?group=" + group + "&pageNum=" + page req = public.get_data(url) req_dict = json.loads(req) return render( request, 'onlinecards_list.html', { "data": data, "group": req_dict, "group_id": long(group), "pageNum": long(page) })
def save_report_result(request): build_url = request.GET.get("build_url") job_record_id = request.GET.get("job_record_id") user_email = request.GET.get("user_email") json_url = build_url + "api/json?pretty=true" result_url = build_url + "consoleText" param = get_next_job_param(result_url, job_record_id) ret = json.loads(public.get_data(json_url)) if ret.get("result") != "SUCCESS": status = public.STATUS_FAIL else: status = public.STATUS_PASS data = {"status": status, "build_url": build_url, "job_record_id": job_record_id, "user_email": user_email, "param": param} jenkins_update_status(data)
def deadlist(request): ''' 死链列表 :param request: :return: ''' ret = {} page=request.GET.get("page") url=public.JAVA_HOST + "/deadlink/api/results?page="+page req = public.get_data(url) compressedData = json.loads(req) if request.GET.get('page'): page = int(request.GET.get('page')) else: page = 1 if compressedData: if compressedData["size"]%10 >0: ret['last_page']=compressedData["size"]/10+1 else: ret['last_page']=compressedData["size"]/10 else: ret['last_page']=0 if ret['last_page'] <= 5: ret['pages'] = range(1, ret['last_page'] + 1) else: if page < 3: ret['pages'] = range(1,6) else: if page + 3 <= ret['last_page']: ret['pages'] = range(page-2,page+3) elif page < ret['last_page']: if ret['last_page'] - 5 < page: ret['pages'] = range(ret['last_page']-4, ret['last_page']+1) else: ret['pages'] = range(page-2,ret['last_page']+1) else: ret['pages'] = range(page-4, page+1) ret['page'] = page ret['pre'] = page - 1 if page == ret['last_page']: ret['next'] = -1 else: ret['next'] = page + 1 return render(request,'deadList.html',{"data":compressedData['data'],"ret":ret})
def save_report_result(request): build_url = request.GET.get("build_url") job_record_id = request.GET.get("job_record_id") user_email = request.GET.get("user_email") json_url = build_url + "api/json?pretty=true" result_url = build_url + "consoleText" param = get_next_job_param(result_url, job_record_id) ret = json.loads(public.get_data(json_url)) if ret.get("result") != "SUCCESS": status = public.STATUS_FAIL else: status = public.STATUS_PASS data = { "status": status, "build_url": build_url, "job_record_id": job_record_id, "user_email": user_email, "param": param } jenkins_update_status(data)
def get_next_job_param(url, job_record_id): #传递参数格式为: NEXT_JOB_PARAM=key::value&&key1::value1 params = {} ret = public.get_data(url) start_index = ret.rfind(public.JOB_PARAM) if start_index == -1: return params ret = ret[start_index:] end_index = ret.find("\n") param = public.JOB_PARAM + "=" ret = ret[:end_index].strip().replace(" ", "").replace(param, "").split("&&") job_record = models.JobRecord.objects.get(id=job_record_id) task_record_id = job_record.task_record_id task_record = models.TaskRecord.objects.get(id=task_record_id) params = json.loads(task_record.params) if task_record.params else {} for r in ret: tmp = r.strip().split("::") if len(tmp) == 2: params[tmp[0]] = tmp[1] task_record.params = json.dumps(params) task_record.save() return params
def get_job_config(self, name): job_url = "%s/job/%s/api/json?pretty=true" % (self.jenkins_url, name) ret = json.loads(public.get_data(job_url)) return ret