def get_branch_svn_log(request): """ :author: yechengzhou :param request: request should contains branch name and module name :return: json format branch svn log """ if request.method != "GET": return public.fail_result_http(u"该接口只支持GET") else: module = request.GET.get('module') branch = request.GET.get('branch') type = request.GET.get('type') # 0 -- one day 1 -- last 10 if not (module and branch): return public.fail_result_http(u"参数错误") else: if type == '0' or type == None: if branch != "trunk": start = branch.split('_')[-2] start_time = public.str2datetime(start, "%Y%m%d") end_time = start_time + datetime.timedelta(days=1) end = public.datetime2str(end_time, "%Y%m%d") ret = utils.get_branch_svn_log(module,branch, start, end) else: ret = utils.get_branch_svn_log(module,branch) elif type == '1': ret = utils.get_branch_svn_log(module,branch ) return public.success_result_http(ret)
def get_branch_svn_log(request): """ :author: yechengzhou :param request: request should contains branch name and module name :return: json format branch svn log """ if request.method != "GET": return public.fail_result_http(u"该接口只支持GET") else: module = request.GET.get('module') branch = request.GET.get('branch') type = request.GET.get('type') # 0 -- one day 1 -- last 10 if not (module and branch): return public.fail_result_http(u"参数错误") else: if type == '0' or type == None: if branch != "trunk": start = branch.split('_')[-2] start_time = public.str2datetime(start, "%Y%m%d") end_time = start_time + datetime.timedelta(days=1) end = public.datetime2str(end_time, "%Y%m%d") ret = utils.get_branch_svn_log(module, branch, start, end) else: ret = utils.get_branch_svn_log(module, branch) elif type == '1': ret = utils.get_branch_svn_log(module, branch) return public.success_result_http(ret)
def getProduct_cards(data): """ liujichao 获取未发布上线单内容 """ now = public.str2datetime(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())), "%Y-%m-%d %H:%M:%S") retData={} try: jsdata=json.loads(data) endDate=jsdata['endDate'] #结束时间 listData=jsdata['listData'] for tmp in listData: info=tmp['info'] groups = data_mgr.models.Group.objects.filter(ckpak=info['ckPak']) m=models.ProductCard.objects.filter(op_card_id=tmp['id']) if 0==len(groups): print "groups 表中不存在的分组",info['ckPak'] if 0 != len(groups): if 0 == len(m): s=models.ProductCard() taskName=tmp['task_name'] #是否过测试 if u"不过测试" in taskName: s.need_qa=0 else: s.qa_owner=info['testMan'] s.test_result=info['addData_ret'] s.need_qa=1 s.endDate=endDate s.op_card_id=tmp['id'] s.rd_owner=info['devMan'] #研发负责人 if not info.has_key("publish_mode"): count="" module =info['modName'] for temp in module: if temp !="": count=count+temp+"," s.module_name=count else: s.module_name=info['publish_mode'] #模块名称 s.card_type=info['publish_type'] #提测单类型 s.pm_owner=info['goodsMan']#产品负责人 if not info.has_key('addData_req'): s.content=info['projectName'] else: s.content=info['addData_req'] #提测单的内容 s.online_suggestion=info['addData_mymemo'] #上线意见 s.group_id = groups[0].id s.save() retData['code']="0" retData['message']="success" return retData except Exception as err: retData['code']="-1" retData['message']="fail" return retData
def svn_history_only(request): module = request.GET.get('module') branch = request.GET.get('branch') sn = request.GET.get('sn') start = branch.split('_')[-2] start_time = public.str2datetime(start, "%Y%m%d") end_time = start_time + datetime.timedelta(days=1) end = public.datetime2str(end_time, "%Y%m%d") #start = request.GET.get("start") #end = request.GET.get("end") import re ret = [] sn_dict = {} sn_dict['no_sn'] = [] if not (module and branch): return public.fail_result_http(u"参数错误") else: tmp_ret = data_utils.get_branch_svn_log(module, branch, start, end) #get all sn sn_list = [] for r in tmp_ret: tmp = r.get('comment') this_sn = tmp[tmp.find('sn=') + 3:tmp.find(';')].strip() if this_sn in sn_list: continue else: if re.match('^\d+$', this_sn): sn_list.append(this_sn) else: continue for r in tmp_ret: comment = r.get('comment') if comment.find('sn=') != -1: sn_no = comment[comment.find('sn=') + 3:comment.find(';')].strip() if re.match('^\d+$', sn_no): if sn_dict.has_key(sn_no): sn_dict[sn_no].append(r) else: sn_dict[sn_no] = [r] else: sn_dict['no_sn'].append(r) return render(request, 'commitlist.html', { 'data': sn_dict, 'sns': sn_list, })
def online_info(request): name = "agile" view = data_utils.JenkinsInfo(name) ret = [] online_info_dict = data_utils.get_online_info() for i in view.get_ret(): if i['name'].startswith("newlabs_"): i['jobname'] = i['name'] i['name'] = i['name'][8:] ### if online_info_dict: online_info = online_info_dict.get(i['name'].capitalize()) else: online_info = None if online_info != None: i['has_online_version'] = True i['online_version'] = online_info.get('version') # get online version svn info branch = online_info.get('version') start = branch.split('_')[-2] start_time = public.str2datetime(start, "%Y%m%d") end_time = start_time + datetime.timedelta(days=1) end = public.datetime2str(end_time, "%Y%m%d") this_svn = data_utils.get_branch_svn_log( i['name'], branch, start, end) sn_dict = {} sn_dict['no_sn'] = [] if this_svn: for r in this_svn: # get sn and group by sn comment = r.get('comment') if comment.find('sn=') != -1: sn_no = comment[comment.find('sn=') + 3:comment.find(';')].strip() if re.match('^\d+$', sn_no): if sn_dict.has_key(sn_no): sn_dict[sn_no].append(r) else: sn_dict[sn_no] = [r] else: sn_dict['no_sn'].append(r) i['svn_info'] = sn_dict ret.append(i) return render(request, 'online.html', {'data': ret})
def testsave(data): rt={} now = public.str2datetime(time.strftime('%Y-%m-%d', time.localtime(time.time())), "%Y-%m-%d") m = models.Pushstatus() m.nowTime = now rt['nowtime']=m.nowTime m.endFlag = "0" rt['nowtime']=m.endFlag m.update_Time=now rt['update_Time']=m.update_Time m.area="GZ" rt['area']=m.area m.version="RB_groupon_20160121_153921" rt['version']=m.version m.save() return rt
def online_info(request): name = "agile" view = data_utils.JenkinsInfo(name) ret = [] online_info_dict = data_utils.get_online_info() for i in view.get_ret(): if i['name'].startswith("newlabs_"): i['jobname'] = i['name'] i['name'] = i['name'][8:] ### if online_info_dict: online_info = online_info_dict.get(i['name'].capitalize()) else: online_info = None if online_info != None: i['has_online_version'] = True i['online_version'] = online_info.get('version') # get online version svn info branch = online_info.get('version') start = branch.split('_')[-2] start_time = public.str2datetime(start, "%Y%m%d") end_time = start_time + datetime.timedelta(days=1) end = public.datetime2str(end_time, "%Y%m%d") this_svn = data_utils.get_branch_svn_log(i['name'],branch, start, end) sn_dict = {} sn_dict['no_sn'] = [] if this_svn: for r in this_svn: # get sn and group by sn comment = r.get('comment') if comment.find('sn=') != -1: sn_no = comment[comment.find('sn=') + 3: comment.find(';')].strip() if re.match('^\d+$',sn_no): if sn_dict.has_key(sn_no): sn_dict[sn_no].append(r) else: sn_dict[sn_no] = [r] else: sn_dict['no_sn'].append(r) i['svn_info'] = sn_dict ret.append(i) return render(request, 'online.html', {'data': ret})
def svn_history_only(request): module = request.GET.get('module') branch = request.GET.get('branch') sn = request.GET.get('sn') start = branch.split('_')[-2] start_time = public.str2datetime(start, "%Y%m%d") end_time = start_time + datetime.timedelta(days=1) end = public.datetime2str(end_time, "%Y%m%d") #start = request.GET.get("start") #end = request.GET.get("end") import re ret = [] sn_dict = {} sn_dict['no_sn'] = [] if not (module and branch): return public.fail_result_http(u"参数错误") else: tmp_ret = data_utils.get_branch_svn_log(module,branch, start, end) #get all sn sn_list = [] for r in tmp_ret: tmp = r.get('comment') this_sn = tmp[tmp.find('sn=') + 3: tmp.find(';')].strip() if this_sn in sn_list: continue else: if re.match('^\d+$',this_sn): sn_list.append(this_sn) else: continue for r in tmp_ret: comment = r.get('comment') if comment.find('sn=') != -1: sn_no = comment[comment.find('sn=') + 3: comment.find(';')].strip() if re.match('^\d+$',sn_no): if sn_dict.has_key(sn_no): sn_dict[sn_no].append(r) else: sn_dict[sn_no] = [r] else: sn_dict['no_sn'].append(r) return render(request, 'commitlist.html',{'data':sn_dict, 'sns': sn_list, })
def save_push_status(data): """ liujichao 存储上线状态 数据 """ try: retData={} jsonReq = json.loads(data); if len(jsonReq) ==0: retData['code']="1" retData['message']="暂无数据" return retData now = public.str2datetime(time.strftime('%Y-%m-%d', time.localtime(time.time())), "%Y-%m-%d") for tmp in jsonReq: if "BJ" in tmp: area="BJ" elif "DFZ" in tmp: area="DFZ" else: area="GZ" s=models.Pushstatus.objects.filter(nowTime__gt=now,area=area,version=jsonReq[tmp]['version']) if len(s): if s[0].endFlag != jsonReq[tmp]['endflag']: s[0].endFlag=jsonReq[tmp]['endflag'] s.update(endFlag=jsonReq[tmp]['endflag']) else: m = models.Pushstatus() m.nowTime = now m.endFlag = jsonReq[tmp]['endflag'] m.update_Time=jsonReq[tmp]['updated_at'] m.area=area m.version=jsonReq[tmp]['version'] m.save() retData['code']="0" retData['message']="success" return retData except Exception as err: print err retData['code']="-1" retData['message']="fail" return retData