コード例 #1
0
 def delete_ci_task(request, task_id):
     ci_task = CITask.objects.get(int(task_id))
     CITaskConfigService.delete_config(ci_task.TaskConfig)
     CITaskHistoryService.clean_all_history(task_id, True)
     ci_task.IsActive = 0
     ci_task.save()
     CITaskService.log_delete_activity(request.user, ci_task)
コード例 #2
0
 def get(self, request, *args, **kwargs):
     result = "ok"
     try:
         history_id = self.kwargs['history_id']
         CITaskHistoryService.clean_build_history(history_id)
     except Exception as ex:
         result = str(ex)
         SimpleLogger.exception(ex)
     return Response(str(result))
コード例 #3
0
 def get(self, request, *args, **kwargs):
     tq_id = self.kwargs.get("tq_id", "")
     task_history = CITaskHistory.objects.get_by_tqid(int(tq_id))
     CITaskHistoryService.save_build_log(tq_id)
     CITaskHistoryService.clean_build_history(task_history.id)
     CITQService.update_task_queue_status(request)
     CITaskService.send_task_enqueue_message()
     return Response({"message", "task_done"},
                     status=status.HTTP_201_CREATED)
コード例 #4
0
def tq_done(request):
    try:
        tq_id = request.GET.get("tq_id", "")
        task_history = CITaskHistory.objects.get_by_tqid(int(tq_id))
        CITaskHistoryService.save_build_log(tq_id)
        CITaskHistoryService.clean_build_history(task_history.id)
        CITQService.update_task_queue_status(request)
        CITaskService.send_task_enqueue_message()
        result = SuccessResponse("success", dict())
    except Exception as ex:
        SimpleLogger.exception(ex)
        result = ErrorResponse(str(ex), dict())
    return HttpResponse(result.get_json())
コード例 #5
0
 def get(self, request, *args, **kwargs):
     message = "success"
     try:
         print(self.request.GET)
         status = self.request.GET.get('status', 5)
         build_message = self.request.GET.get('error_msg', '')
         task_queue = self.get_object()
         CITaskHistoryService.save_build_log(str(task_queue.id), True)
         CITQService.update_task_queue_status(task_queue.id, status,
                                              build_message)
         CITaskService.send_task_enqueue_message()
     except Exception as ex:
         print(ex)
         message = str(ex)
     return response.Response({"message": message})
コード例 #6
0
 def change_logs(self):
     result = list()
     try:
         change_logs = CITaskHistoryService.get_change_log(
             self.ci_task_history.ChangeLog)
         json_decoder = JSONDecoder()
         if change_logs:
             all_resp_changes = json_decoder.decode(
                 change_logs['change_log'])
             index = 1
             for resp_changes in all_resp_changes:
                 repo = resp_changes['repo']
                 for changes in resp_changes['changes']:
                     temp_changelog = VM_CITaskChangeLog(
                         changes, index, repo)
                     result.append(temp_changelog)
                     index = index + 1
         elif self.ci_task_history.CodeVersion:
             all_changes = json_decoder.decode(
                 self.ci_task_history.CodeVersion)
             temp_changelog = VM_CITaskChangeLog(all_changes[0], 0, "")
             result.append(temp_changelog)
     except Exception as ex:
         SimpleLogger.exception(ex)
     return result
コード例 #7
0
ファイル: vm_ci_task.py プロジェクト: zzzz123321/Teamcat
 def last_run_time(self):
     result = "从未运行过"
     last_history = CITaskHistoryService.get_finished_history(
         self.ci_task.id)
     if len(last_history):
         result = last_history[0].CreateTime
     return result
コード例 #8
0
 def ci_testing_history_list(self,task_id):
     dm_task_histories=dm_task_histories=CITaskHistoryService.get_finished_history(task_id)
     vm_task_histories=list()
     for history in dm_task_histories:
         temp_history=VM_CITaskHistory(history,None)
         vm_task_histories.append(temp_history)
     pagefileds = {"ci_task_histories":vm_task_histories}
     return self.get_webpart(pagefileds, TestingTaskPath.testing_history_list)
コード例 #9
0
 def get(self, request, *args, **kwargs):
     result = ""
     history_id = int(self.kwargs['history_id'])
     history = CITaskHistory.objects.get(history_id)
     if history.ChangeLog:
         result = CITaskHistoryService.get_change_log(history.ChangeLog)
         result.pop('_id')
     return Response(str(result))
コード例 #10
0
 def get(self, request, *args, **kwargs):
     result = None
     output_id = int(self.kwargs.get("output_id", 0))
     output = CITaskStepOutput.objects.get(output_id)
     if output.ProductID:
         temp_output = CITaskHistoryService.get_log_content(output, True)
         result = temp_output
     return Response(result)
コード例 #11
0
 def patch(self, request, *args, **kwargs):
     change_log = request.data.get("ChangeLog")
     tags = request.data.get("Tags")
     if change_log:
         request.data["ChangeLog"] = str(CITaskHistoryService.save_change_log(change_log))
     if tags:
         self.archive_package(tags, kwargs['id'])
     return self.partial_update(request)
コード例 #12
0
ファイル: vm_ci_task.py プロジェクト: honolulu0/TeamVision1
 def last_build_success(self):
     result="status-background-default"
     last_history=CITaskHistoryService.get_finished_history(self.ci_task.id)
     if len(last_history):
         if last_history[0].BuildStatus==1:
             result="status-background-success"
         if last_history[0].BuildStatus==2:
             result="status-background-fail"
         if last_history[0].BuildStatus==3:
             result="status-background-cancel"
     return result
コード例 #13
0
 def get_finished_step_log(self, task_history_id):
     result = None
     step_outputs = CITaskStepOutput.objects.filter(
         TaskHistoryID=int(task_history_id)).filter(
             StageHistoryID=0).filter(ProductType=1)
     if len(step_outputs) > 0:
         if step_outputs[0].ProductID:
             contents = CITaskHistoryService.get_big_build_log(
                 step_outputs[0].ProductID)
             temp_output = dict()
             temp_output["id"] = step_outputs[0].id
             temp_output["step_name"] = "完成"
             c = contents.read()
             log_content = c.decode('utf-8')
             log_content = CITaskHistoryService.format_build_log(
                 log_content)
             temp_output["log_content"] = log_content
             temp_output["show_content"] = True
             result = temp_output
     return result
コード例 #14
0
 def get_ci_task_history_list(self, task_id):
     dm_task_histories = dm_task_histories = CITaskHistoryService.get_finished_history(
         task_id)[0:9]
     vm_task_histories = list()
     for history in dm_task_histories:
         tag_menu = self.get_task_tag_menu(history, "ci-history-tag-inline",
                                           2)
         temp_history = VM_CITaskHistory(history, tag_menu)
         vm_task_histories.append(temp_history)
     pagefileds = {"ci_task_histories": vm_task_histories}
     return self.get_webpart(pagefileds, CITaskPath.task_history_list)
コード例 #15
0
 def render_new_data(self, data, renderer_context):
     new_data = OrderedDict()
     detail_data = OrderedDict()
     task_id = int(renderer_context['kwargs']['task_id'])
     detail_data[
         'latest_code_version'] = CITaskHistoryService.get_latest_codeversion(
             task_id)
     detail_data['all_histories'] = data
     new_data['code'] = renderer_context['response'].status_code
     new_data['message'] = renderer_context['response'].status_text
     new_data['result'] = detail_data
     return new_data
コード例 #16
0
 def save_ci_taskhistory(request, task_queue, ci_task, project_version):
     if not project_version:
         project_latest_version = CITaskService.get_project_latest_version(
             ci_task.Project)
     else:
         project_latest_version = int(project_version)
     task_history = CITaskHistory()
     task_history.CITaskID = ci_task.id
     task_history.TaskUUID = task_queue.TaskUUID
     task_history.IsActive = 1
     task_history.Status = 0
     if request.user.id != None:
         task_history.StartedBy = request.user.id
     else:
         task_history.StartedBy = 0
     task_history.BuildVersion = ci_task.BuildVersion
     task_history.ProjectVersion = project_latest_version
     task_history.BuildParameterID = task_queue.BuildParameterID
     task_history.save()
     CITaskHistoryService.remove_build_history(ci_task.id)
     return task_history.id
コード例 #17
0
 def task_more_changelog_list(self, request, task_id):
     page_size = int(request.POST.get("page_size", 0))
     start_index = int((page_size / 9) * 9)
     end_index = int(((page_size / 9) + 1) * 9)
     dm_task_histories = CITaskHistoryService.get_finished_history(
         task_id)[start_index:end_index]
     vm_task_histories = list()
     for history in dm_task_histories:
         temp_history = VM_CITaskHistory(history, None)
         vm_task_histories.append(temp_history)
     pagefileds = {"task_histories": vm_task_histories}
     return self.get_webpart(pagefileds, CITaskPath.task_changelog_list)
コード例 #18
0
 def file_iterator(chunk_size=1024 * 2):
     while True:
         try:
             c = contents.read(chunk_size)
             result = c.decode('utf-8')
             result = CITaskHistoryService.format_build_log(result)
             if c:
                 yield result
             else:
                 break
         except Exception as ex:
             SimpleLogger.exception(ex)
             continue
コード例 #19
0
 def task_more_history_list(self, request, task_id):
     page_size = int(request.POST.get("page_size", 0))
     start_index = int((page_size / 9) * 9)
     end_index = int(((page_size / 9) + 1) * 9)
     vm_task_histories = list()
     dm_task_histories = CITaskHistoryService.get_finished_history(
         task_id)[start_index:end_index]
     for history in dm_task_histories:
         tag_menu = self.get_task_tag_menu(history, "ci-history-tag-inline",
                                           2)
         temp_history = VM_CITaskHistory(history, tag_menu)
         vm_task_histories.append(temp_history)
     pagefileds = {"ci_task_histories": vm_task_histories}
     return self.get_webpart(pagefileds, CITaskPath.task_history_list)
コード例 #20
0
 def ci_testing_history_webpart(self, request,task_id):
     task_historys=CITaskHistoryService.get_finished_history(task_id)
     first_history_id=0
     first_history=None
     if len(task_historys):
         first_history=task_historys[0]
         first_history_id=task_historys[0].id
     testing_history_result_list = self.ci_testing_history_list(task_id)
     testing_history_analytics=self.testing_history_analytics(first_history_id)
     testing_case_result_list=self.testing_case_result_list(first_history_id,0,count=20)
     ci_task=CITask.objects.get(int(task_id))
     pagefileds = {"testing_history_result_list":testing_history_result_list,"ci_task":ci_task}
     pagefileds['testing_history_analytics']=testing_history_analytics
     pagefileds['testing_case_result_list']=testing_case_result_list
     pagefileds['ci_history']=first_history
     return self.get_webpart(pagefileds,TestingTaskPath.teting_history_page)
コード例 #21
0
 def task_changelog_detail(self, history_id, select_version):
     result = None
     history = CITaskHistory.objects.get(int(history_id), is_active=0)
     change_logs = CITaskHistoryService.get_change_log(history.ChangeLog)
     json_decoder = JSONDecoder()
     if change_logs:
         all_resp_changes = json_decoder.decode(change_logs['change_log'])
         for resp_changes in all_resp_changes:
             repo = resp_changes['repo']
             for changes in resp_changes['changes']:
                 temp_changelog = VM_CITaskChangeLog(changes, 0, repo)
                 if temp_changelog.version == select_version:
                     result = temp_changelog
                     break
             if result:
                 break
     pagefileds = {"changefile": result}
     return self.get_webpart(pagefileds, CITaskPath.task_changelog_detail)
コード例 #22
0
def get_build_log(request, file_id):
    contents = CITaskHistoryService.get_big_build_log(request, file_id)

    def file_iterator(chunk_size=1024 * 2):
        while True:
            try:
                c = contents.read(chunk_size)
                result = c.decode('utf-8')
                result = CITaskHistoryService.format_build_log(result)
                if c:
                    yield result
                else:
                    break
            except Exception as ex:
                SimpleLogger.exception(ex)
                continue

    def file_iterator2(chunk_size=1024 * 2):
        while True:
            try:
                c = contents.read(chunk_size)
                result = c.decode('utf-8')
                result = CITaskHistoryService.format_build_log(result)
                result = result.replace("</br>", '\r\n')
                if c:
                    yield result
                else:
                    break
            except Exception as ex:
                SimpleLogger.exception(ex)
                continue

    if contents.length > 1024 * 1024 * 10:
        file = FileInfo.objects.get(int(file_id))
        result = StreamingHttpResponse(file_iterator2(),
                                       content_type='application/octet-stream')
        display_file_name = str(file.FileName.encode("utf-8")).replace(
            "'", "").replace("b'", '')
        result[
            'Content-Disposition'] = 'attachment;filename="' + display_file_name + '"'
    else:
        result = StreamingHttpResponse(file_iterator(),
                                       content_type='text/html')
    return result
コード例 #23
0
 def get(self, request, *args, **kwargs):
     result = list()
     stage_history_id = self.kwargs['stage_history_id']
     step_outputs = CITaskStepOutput.objects.filter(
         StageHistoryID=int(stage_history_id)).filter(
             ProductType=1).order_by('id')
     stage_history = CITaskStageHistory.objects.get(int(stage_history_id))
     task_history_id = 0
     for output in step_outputs:
         task_history_id = output.TaskHistoryID
         if output.ProductID:
             temp_output = CITaskHistoryService.get_log_content(
                 output, False)
             result.append(temp_output)
     if task_history_id != 0 and self.is_last_stage(stage_history):
         last_output = self.get_finished_step_log(task_history_id)
         if last_output is not None:
             result.append(last_output)
     return Response(result)
コード例 #24
0
 def post(self, request, *args, **kwargs):
     out_put = CITaskHistoryService.save_step_log(request.data)
     serializer = ci_taskhistory_serializer.CITaskOutputSerializer(
         instance=out_put)
     return Response(serializer.data, status=status.HTTP_201_CREATED)
コード例 #25
0
 def clean_task_history(request, task_id):
     ci_task = CITask.objects.get(int(task_id))
     CITaskHistoryService.clean_all_history(task_id, False)
     CITaskService.log_clean_activity(request.user, ci_task)
コード例 #26
0
 def post(self, request, *args, **kwargs):
     output_file = CITaskHistoryService.upload_package(request)
     serializer = ci_taskhistory_serializer.CITaskOutputSerializer(
         instance=output_file)
     return Response(serializer.data, status=status.HTTP_201_CREATED)