当前位置: 首页>>代码示例>>Python>>正文


Python FileCacher.destroy_cache方法代码示例

本文整理汇总了Python中cms.db.filecacher.FileCacher.destroy_cache方法的典型用法代码示例。如果您正苦于以下问题:Python FileCacher.destroy_cache方法的具体用法?Python FileCacher.destroy_cache怎么用?Python FileCacher.destroy_cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cms.db.filecacher.FileCacher的用法示例。


在下文中一共展示了FileCacher.destroy_cache方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make

# 需要导入模块: from cms.db.filecacher import FileCacher [as 别名]
# 或者: from cms.db.filecacher.FileCacher import destroy_cache [as 别名]
    def make(self):
        # Unset stack size limit
        resource.setrlimit(resource.RLIMIT_STACK, (resource.RLIM_INFINITY,
                                                   resource.RLIM_INFINITY))

        if not os.path.exists(os.path.join(self.odir, "contest-config.py")):
            raise Exception("Directory doesn't contain contest-config.py")
        self.wdir = os.path.join(self.odir, "build")
        if self.clean:
            shutil.rmtree(self.wdir)
        if not os.path.exists(self.wdir):
            os.mkdir(self.wdir)
        # We have to avoid copying the folder contest/build
        # or contest/task/build into contest/build.
        # For this reason, we ignore all files and directories named "build"
        # when copying recursively.
        copyrecursivelyifnecessary(self.odir, self.wdir, set(["build"]))
        self.wdir = os.path.abspath(self.wdir)
        file_cacher = FileCacher(path=os.path.join(self.wdir, ".cache"))
        try:
            with chdir(self.wdir):
                contestconfig = ContestConfig(
                    os.path.join(self.wdir, ".rules"),
                    os.path.basename(self.odir),
                    ignore_latex=self.no_latex,
                    onlytask=self.task)
                contestconfig._readconfig("contest-config.py")
                if self.task is not None and len(contestconfig.tasks) == 0:
                    raise Exception("Task {} not found".format(self.task))
                cdb = contestconfig._makecontest()
                test_udb = contestconfig._makeuser(
                    contestconfig._mytestuser.username)
                test_gdb = contestconfig._makegroup(
                    contestconfig._mytestuser.group.name, cdb)
                # We're not putting the test user on any team for testing
                # (shouldn't be needed).
                test_pdb = contestconfig._makeparticipation(
                    contestconfig._mytestuser.username, cdb,
                    test_udb, test_gdb, None)
                for t in contestconfig.tasks.values():
                    tdb = t._makedbobject(cdb, file_cacher)
                    t._make_test_submissions(test_pdb, tdb, self.local_test)
        finally:
            file_cacher.destroy_cache()
开发者ID:ioi-germany,项目名称:cms,代码行数:46,代码来源:GerMake.py

示例2: build

# 需要导入模块: from cms.db.filecacher import FileCacher [as 别名]
# 或者: from cms.db.filecacher.FileCacher import destroy_cache [as 别名]
    def build(self):
        file_cacher = FileCacher(path=os.path.join(self.wdir, ".cache"))

        try:
            with chdir(self.wdir):
                contestconfig = \
                    ContestConfig(os.path.join(self.wdir, ".rules"),
                                  "hidden contest", minimal=self.minimal)
                copyifnecessary(os.path.join(contestconfig._get_ready_dir(),
                                             "contest-template.py"),
                                os.path.join(self.wdir, "c.py"))
                contestconfig._readconfig("c.py")
                contestconfig._task(
                    self.task, contestconfig.full_feedback, self.minimal)

                if not self.minimal:
                    cdb = contestconfig._makecontest()
                    test_udb = contestconfig._makeuser(
                        contestconfig._mytestuser.username)
                    test_gdb = contestconfig._makegroup(
                        contestconfig._mytestuser.group.name, cdb)
                    # We're not putting the test user on any team for testing
                    # (shouldn't be needed).
                    test_pdb = contestconfig._makeparticipation(
                        contestconfig._mytestuser.username, cdb,
                        test_udb, test_gdb, None)
                    for t in contestconfig.tasks.values():
                        tdb = t._makedbobject(cdb, file_cacher)
                        t._make_test_submissions(
                            test_pdb, tdb, self.local_test)

        finally:
            file_cacher.destroy_cache()

        primary_statements = [s for s in list(list(contestconfig.tasks.values())[
            0]._statements.values()) if s.primary]
        if len(primary_statements) == 0:
            return None
        elif len(primary_statements) == 1:
            return os.path.abspath(primary_statements[0].file_)
        else:
            raise Exception("More than one primary statement")
开发者ID:ioi-germany,项目名称:cms,代码行数:44,代码来源:GerMakeTask.py

示例3: GerImport

# 需要导入模块: from cms.db.filecacher import FileCacher [as 别名]
# 或者: from cms.db.filecacher.FileCacher import destroy_cache [as 别名]
class GerImport(Service):
    def __init__(self, odir, no_test, clean, force):
        self.odir = odir
        self.no_test = no_test
        self.clean = clean
        self.force = force

        Service.__init__(self)

    def make(self):
        self.file_cacher = FileCacher()
        try:
            self.make_helper()
        finally:
            self.file_cacher.destroy_cache()

    def make_helper(self):
        # Unset stack size limit
        resource.setrlimit(resource.RLIMIT_STACK, (resource.RLIM_INFINITY,
                                                   resource.RLIM_INFINITY))

        if not os.path.exists(os.path.join(self.odir, "contest-config.py")):
            raise Exception("Directory doesn't contain contest-config.py")
        self.wdir = os.path.join(self.odir, "build")
        if self.clean:
            shutil.rmtree(self.wdir)
        if not os.path.exists(self.wdir):
            os.mkdir(self.wdir)
        # We have to avoid copying the folder contest/build
        # or contest/task/build into contest/build.
        # For this reason, we ignore all files and directories named "build"
        # when copying recursively.
        copyrecursivelyifnecessary(self.odir, self.wdir, set(["build"]))

        self.wdir = os.path.abspath(self.wdir)
        with chdir(self.wdir):
            contestconfig = ContestConfig(
                os.path.join(self.wdir, ".rules"),
                os.path.basename(self.odir))

            # Read the configuration file and build.
            contestconfig._readconfig("contest-config.py")

            with SessionGen() as session:
                def session_add(k, v):
                    session.add(v)

                # Variables like udbs, teamdbs, cdb, ... contain objects before
                # they've been put into the database.
                # Their counterpars udb1s, teamdb1s, cdb1, ... contain the
                # objects that are actually in the database (which are copies
                # of the objects in udbs, ...).

                # Create users in the database.
                udbs = [contestconfig._makeuser(u) for u in contestconfig.users]
                udb1s = _update_list_with_key(session.query(User).all(),
                                              udbs,
                                              lambda u : u.username,
                                              preserve_old=True,
                                              update_value_fn=update_user,
                                              creator_fn=session_add)
                udbs = {u.username : u for u in udbs}

                # Create teams in the database.
                teamdbs = [contestconfig._maketeam(t) for t in contestconfig.teams]
                teamdb1s = _update_list_with_key(session.query(Team).all(),
                                                 teamdbs,
                                                 lambda t : t.code,
                                                 preserve_old=True,
                                                 update_value_fn=update_team,
                                                 creator_fn=session_add)
                teamdbs = {t.code : t for t in teamdbs}

                # Create contest (including associated user groups) in the database.
                cdb = contestconfig._makecontest()
                cdbs = [cdb]
                cdb1s = _update_list_with_key(session.query(Contest).all(),
                                              cdbs,
                                              lambda c : c.name,
                                              preserve_old=True,
                                              update_value_fn=update_contest,
                                              creator_fn=session_add)
                cdb1 = cdb1s[cdb.name]

                # Set the contest's main group.
                cdb1.main_group = cdb1.get_group(contestconfig.defaultgroup.name)

                # Create participations in the database.

                # Team object for a given user
                def user_team(u):
                    t = contestconfig.users[u].team
                    if t is None:
                        return None
                    else:
                        return teamdbs[t.code]
                # Team object in the database for a given user
                def user_team1(u):
                    t = contestconfig.users[u].team
                    if t is None:
#.........这里部分代码省略.........
开发者ID:ioi-germany,项目名称:cms,代码行数:103,代码来源:GerImport.py


注:本文中的cms.db.filecacher.FileCacher.destroy_cache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。