def upload_package(request): result=0 tq_id=request.POST.get('tq_id','') file_type=request.POST.get('file_type','') upload_file=request.FILES['upload_file'] max_file_size=SystemConfigService.get_upload_file_maxsize() file_wihte_list=SystemConfigService.get_file_type_white_list() if CITaskService.validate_upload_file(upload_file,max_file_size,file_wihte_list): mongo_fileid=MongoDBService.save_file(upload_file,PackgeMongoFile) result=FileInfoService.add_file(0,mongo_fileid, upload_file.name,1,0,upload_file.size) CITaskService.update_ci_taskhistory(tq_id,result,file_type) return result
def upload_package(request): result = None upload_file = request.FILES['upload_file'] max_file_size = SystemConfigService.get_upload_file_maxsize() file_wihte_list = SystemConfigService.get_file_type_white_list() if CITaskHistoryService.validate_upload_file(upload_file, max_file_size, file_wihte_list): mongo_fileid = MongoDBService.save_file(upload_file, PackgeMongoFile) file_id = FileInfoService.add_file(0, mongo_fileid, upload_file.name, 1, 0, upload_file.size) temp_output = CITaskStepOutput() temp_output = CITaskHistoryService.init_step_output(temp_output,request.data) temp_output.ProductID = file_id temp_output.save() result = temp_output return result
def send_notification_email(task_id, email_message): ci_task = CITask.objects.get(int(task_id)) email_list = CITaskParameterService.get_email_list(ci_task.Project) email_config = SystemConfigService.get_email_config() subject = "发布参数值正在被修改!!!" CITaskParameterService.send_email(email_config, email_list, email_message, subject)
def host_env_dropdown_list(self, selected_text): vm_data_values = list() for dm_data_value in SystemConfigService.test_env(): tem_data = VM_DataValue(dm_data_value,selected_text) vm_data_values.append(tem_data) pagefileds = {"build_tools":vm_data_values} return self.get_webpart(pagefileds, CICommonControllPath.build_tool_testenv)
def get_pods_buildtools_dropdown_list(self, select_value): vm_data_values = list() for dm_data_value in SystemConfigService.get_pods_build_tools(): tem_data = VM_DataValue(dm_data_value,select_value) vm_data_values.append(tem_data) pagefileds = {"build_tools":vm_data_values} return self.get_webpart(pagefileds, CICommonControllPath.build_tool_pods)
def get_credential_type_dropdown_list(self, selected_credential_id): vm_data_values = list() for dm_data_value in SystemConfigService.get_credential_type(): tem_data = VM_DataValue(dm_data_value, selected_credential_id) vm_data_values.append(tem_data) pagefileds = {"credentials":vm_data_values} return self.get_webpart(pagefileds, CICommonControllPath.credential_type_dropdownlist_controll)
def action_project(self): if self.action_log.ProjectID < 0: return SystemConfigService.get_noproject_name( self.action_log.ProjectID) else: project = Project.objects.get(self.action_log.ProjectID) return project.PBTitle
def create_commit_message(fortesting, summary_info, email_template_path): email_templates = open(email_template_path, 'rb').read().decode() project = Project.objects.get(fortesting.ProjectID) projectname = project.PBTitle module = ProjectModule.objects.get(fortesting.ProjectModuleID) module_name = "--" code_addr = ProjectCodeUrl.objects.get(fortesting.ProjectCode) if module: module_name = module.Name platform = SystemConfigService.get_platform_name(project.PBPlatform) submitior = UserService.get_user(fortesting.Commitor) title = "项目:【" + platform + projectname + ForTestingService.get_fortesting_version( fortesting) + "】" + summary_info email_templates = email_templates.replace("${SUBMITIONINFO}", title) email_templates = email_templates.replace("${SUBMITTIME}", str(DateTimeHelper.getcnow())) email_templates = email_templates.replace("${SUBMITID}", str(fortesting.id)) email_templates = email_templates.replace("${PROJECTNAME}", projectname) email_templates = email_templates.replace("${PROJECTMODULENAME}", module_name) email_templates = email_templates.replace("${SUBMITIOR}", str(submitior.last_name + submitior.first_name)) email_templates = email_templates.replace("${PLATFORM}", str(platform)) email_templates = email_templates.replace("${VERSION}", ForTestingService.get_fortesting_version(fortesting)) if code_addr: email_templates = email_templates.replace("${CODEURI}", code_addr.CodeRepertory) email_templates = email_templates.replace("${BRANCH}", code_addr.Branch) else: email_templates = email_templates.replace("${CODEURI}", "") email_templates = email_templates.replace("${BRANCH}", "") email_templates = email_templates.replace("${FUNCTIONCHANGE}", str(fortesting.TestingFeature)) email_templates = email_templates.replace("${SUGGESTION}", str(fortesting.TestingAdvice)) return email_templates
def get_git_checkut_strategy_dropdown_list(self, selected_strategy_id): vm_data_values = list() for dm_data_value in SystemConfigService.get_git_strategy_type(): tem_data = VM_DataValue(dm_data_value, selected_strategy_id) vm_data_values.append(tem_data) pagefileds = {"checkout_strategies":vm_data_values} return self.get_webpart(pagefileds, CICommonControllPath.git_checkout_strategy)
def send_notification_email(issue,summary_info,email_tempalte_path): processor = UserService.get_user(issue.Processor) email_list = [processor.email] email_config = SystemConfigService.get_email_config() email_message = IssueService.create_email_message(issue,summary_info,email_tempalte_path) project_name = Project.objects.get(issue.Project).PBTitle subject = "项目:【" + project_name + "】待处理问题通知" IssueService.send_email(email_config, email_list, email_message, subject)
def update(self, request, *args, **kwargs): result = list() dicdata_list = SystemConfigService.save_dic_datas(request.data) for dicdata in dicdata_list: temp_serlizer = dic_config_serializer.DicConfigSerializer( instance=dicdata) result.append(temp_serlizer.data) return response.Response(result)
def send_notification_email(fortesting_id, summary_info, email_tempalte_path): fortesting = TestApplication.objects.get(fortesting_id) email_list = ForTestingService.get_email_list(fortesting.ProjectID) email_config = SystemConfigService.get_email_config() email_message = ForTestingService.create_email_message(fortesting, summary_info, email_tempalte_path) projectname = Project.objects.get(fortesting.ProjectID).PBTitle subject = "项目:【" + projectname + "】" + summary_info ForTestingService.send_email(email_config, email_list, email_message, subject)
def get_default_email_list(outputemaillist): email_list = outputemaillist email_config = SystemConfigService.get_email_config() emails = email_config['defautrecivers'] for email in emails.split(','): if email in email_list: pass else: email_list.append(email) return email_list
def get_series_data(self): result = list() status_data = TaskStatisticsService.task_count_bystatus( self.project_id, self.version_id, self.request) for data_item in status_data: temp_dict = dict() temp_dict['name'] = SystemConfigService.get_dic_data_name( 'ProjectTaskStatus', data_item.get('Status')) temp_dict['y'] = data_item.get('TotalCount') result.append(temp_dict) return result
def get_device_os_version_controll(self, dm_device, os_value=1): select_value = 0 if dm_device != None: os_value = dm_device.DeviceOS select_value = dm_device.DeviceOSVersion device_os_version = SystemConfigService.get_device_os_version(os_value) if device_os_version == None: return "" return self.get_device_dropdown_controll(device_os_version, select_value)
def get_platform_dropdown_list(self,project_id): vm_platforms=list() platform_value=0 platforms=SystemConfigService.get_platform_configs() if project_id: platform_value=Project.objects.get(project_id).PBPlatform for platform in platforms: tmp_platfrom=VM_Platform(platform,platform_value) vm_platforms.append(tmp_platfrom) pagefileds={"platforms":vm_platforms} return self.get_webpart(pagefileds,ProjectCommonControllPath.platform_dropdown_list_path)
def send_email(emailconfig, emaillist, emailmessage, subject): email_config = SystemConfigService.get_email_config() print(email_config) emailSender = EmailHelper(email_config['Host'],email_config['User'] , email_config['Password'], email_config['Postfix'],email_config['Port']) message = emailSender.generatetextmessage(emailmessage, subject, ','.join(emaillist), 'html') if email_config['Password'].strip() !="": worker = threading.Thread(target=emailSender.sendemaillogin, args=(emaillist, subject, message.as_string())) worker.start() else: worker = threading.Thread(target=emailSender.sendmail_nologin, args=(emaillist, subject, message.as_string())) worker.start()
def get_screen_size_controll(self, dm_device): screen_size = SystemConfigService.get_screen_szie() return self.get_device_dropdown_controll(screen_size, dm_device.DeviceScreenSize)
def platform_title(self): result=SystemConfigService.get_platform_name(self.env.PBPlatform) return result
def file_icon(self): result="default.png" if self.file.FileSuffixes in SystemConfigService.get_file_type_white_list(): result=self.file.FileSuffixes+".png" return "/static/global/images/file_types/"+result
def get_device_os_controll(self, dm_device): device_os = SystemConfigService.get_device_os() return self.get_device_dropdown_controll(device_os, dm_device.DeviceOS)
def device_status(self): return SystemConfigService.get_device_status(self.device.DeviceStatus)
def device_screen(self): result = "--" if self.device.DeviceScreenSize != 0: result = SystemConfigService.get_device_screen_size( self.device.DeviceScreenSize) return result
def device_os_version(self): result = "--" if self.device.DeviceOS != 0: result = SystemConfigService.get_device_version_name( self.device.DeviceOS, self.device.DeviceOSVersion) return result
def set_permission_type(self, permission_type): return SystemConfigService.get_permission_type(permission_type)
def get_content_type_controll(self): permission_types = SystemConfigService.get_permission_types() pagefileds = {"permission_types": permission_types} return self.get_webpart(pagefileds, AdminCommonPath.content_type_dropdownlist)
def get_device_type_controll(self, dm_device): device_type = SystemConfigService.get_device_type() return self.get_device_dropdown_controll(device_type, dm_device.DeviceType)