def save_config(self, configs): self.is_running() if self.type == ProjectTypeEnum.COPY.value: ConfigCopy.copy_config(self.id, configs) elif self.type == ProjectTypeEnum.RELATION.value: ConfigRelation.relation_config(self.id, configs)
def copy_config(): form = CopyConfigForm().validate_for_api() project = Project.query.filter_by(id=form.projectId.data).first_or_404() # 工程运行中不允许修改 project.is_running() # 判断配置存在 ConfigCopy.is_exist(form.id.data) config = ConfigCopy.query.filter_by(id=form.id.data).first() config.updateConfig(form.url.data, form.method.data, form.submit.data, form.header.data, form.data.data, form.deal.data, form.condition.data, form.expect.data, form.assertion.data) return Success('修改配置成功')
def batch(self, create_user_id, scheduler_id): # 获取执行用户信息 task = None create_user = manager.user_model.query.filter_by( id=create_user_id).first() if self.type == ProjectTypeEnum.COPY.value: task = ConfigCopy.batch(self, create_user) elif self.type == ProjectTypeEnum.RELATION.value: task = ConfigRelation.batch(self, create_user) # 执行完毕将结果广播给客户端 api_server = current_app.config.get('API_SERVER') res = requests.get(url=api_server + '/v1/task/finish/' + str(self.id)) current_app.logger.debug(res.text) # 发送邮件 from app.libs.tasks import send_text_email send_text_email.delay(task.id, self.id, scheduler_id)
def get_configs(self): if self.type == ProjectTypeEnum.COPY.value: return ConfigCopy.get_configs(self.id) elif self.type == ProjectTypeEnum.RELATION.value: return ConfigRelation.get_configs(self.id)