def save_to_mongo(file): result = 0 upload_file = file if ForTestingService.validate_upload_file(upload_file, 10 * 1024 * 1024, None): result = MongoDBService.save_file(upload_file, FortestingMongoFile) return result
def cache_issue_attachments(upload_file,user): message = {"cache_key":"","message":"上传文件超过20M"} try: if IssueService.validate_upload_file(upload_file, 20 * 1024 * 1024, None): mongo_id = MongoDBService.save_file(upload_file, TempFileMongoFile) message["cache_key"] = str(mongo_id) except Exception as ex: SimpleLogger.exception(ex) message["message"] = str(ex) return message
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 save_build_log(tq_id): file_name = "ci_build_log" + tq_id + ".log" build_log = RedisService.get_value("ci_build_log" + tq_id) result = MongoDBService.save_content_asfile(file_name, build_log, BuildLogMongoFile) file_id = FileInfoService.add_file(0, result, file_name, 1, 0, len(build_log)) task_history = CITaskHistory.objects.get_by_tqid(int(tq_id)) if file_id: task_history.BuildLogID = file_id else: task_history.BuildLogID = 0 task_history.save()
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 store_cached_file(cached_file_keys): result = "" keys = cached_file_keys.split(',') for key in keys: if key != "": temp_file = RedisService.get_object(key) if temp_file != None: RedisService.delete_value(key) mongo_id = MongoDBService.save_file( temp_file, IssueMongoFile) file_id = FileInfoService.add_file(0, mongo_id, temp_file.name, 1, 0, temp_file.size) if file_id != 0: result = result + str(file_id) + "," return result
def save_build_log(tq_id,tq_done=False): file_name="ci_build_log"+tq_id+".log" build_log=RedisService.get_value("ci_build_log"+tq_id) result=MongoDBService.save_content_asfile(file_name, build_log,BuildLogMongoFile) file_id=FileInfoService.add_file(0,result,file_name,1,0,len(build_log)) RedisService.delete_value("ci_build_log" + tq_id) if tq_done: temp_output = CITaskStepOutput() temp_output.ProductType = 1 temp_output.ProductID = file_id task_queue = TaskQueue.objects.get(int(tq_id)) task_history = CITaskHistory.objects.get_history_by_uuid(task_queue.TaskUUID) temp_output.TaskHistoryID = task_history.id temp_output.TaskID = task_history.CITaskID temp_output.StepID = "" temp_output.StageHistoryID = 0 temp_output.save() else: RedisService.set_value("ci_build_log"+tq_id,"") return file_id
def get_change_log(change_log_id): value = MongoDBService.get("teamcat_log", "code_changelog", change_log_id) return value
def save_change_log(change_log): result = dict() result['change_log'] = change_log mongo_id = MongoDBService.save("teamcat_log", "code_changelog", result) return mongo_id
def save_to_mongo(request): result=0 upload_file=request.FILES['service_file'] if CIService.validate_upload_file(upload_file): result=MongoDBService.save_file(upload_file,CIServiceMongoFile) return result
def save_to_mongo(file, mongo_model): result = ["0", "文件大小不能超过10M"] if BusinessService.validate_upload_file(file, 10 * 1024 * 1024, None): mongo_id = MongoDBService.save_file(file, mongo_model) result[0] = mongo_id return result
def save_to_mongo(request): result = 0 upload_file = request.FILES['avatar_file'] if AccountService.validate_upload_file(upload_file): result = MongoDBService.save_file(upload_file, UCenterMongoFile) return result
def save_to_mongo(file, size, mongo_model): result = 0 upload_file = file if UploadFileService.validate_upload_file(upload_file, size, None): result = MongoDBService.save_file(upload_file, mongo_model) return result