forms.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:afl-mothership 作者: afl-mothership 项目源码 文件源码
def validate(self):
        check_validate = super().validate()
        if not check_validate:
            return False

        campaign = Campaign.get(name=self.name.data)
        if campaign or os.path.exists(os.path.join(current_app.config['DATA_DIRECTORY'], secure_filename(self.name.data))):
            self.name.errors.append('Campaign with that name already exists')
            return False

        if self.copy_of.data == -1:
            if not self.executable.has_file():
                self.executable.errors.append('Must provide an executable or campaign to copy')
                return False
            if not self.testcases.has_file():
                self.testcases.errors.append('Must provide testcases or campaign to copy')
                return False
        else:
            copy_of = Campaign.get(id=self.copy_of.data)
            if not copy_of:
                self.copy_of.errors.append('Campaign to copy does not exist')
                return False

        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号