loader.py 文件源码

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

项目:inmanta 作者: inmanta 项目源码 文件源码
def deploy_version(self, key, mod, persist=False):
        """
            Deploy a new version of the modules

            :param version The version of the deployed modules
            :modules modules A list of module names and the hashes of the code files
        """
        LOGGER.info("Deploying code (key=%s)" % key)
        # deploy the new code
        name = mod[1]
        source_code = mod[2]

        # if the module is new, or update
        if name not in self.__modules or key != self.__modules[name][0]:
            # write the new source
            source_file = os.path.join(self.__code_dir, MODULE_DIR, name + ".py")

            fd = open(source_file, "w+")
            fd.write(source_code)
            fd.close()

            # (re)load the new source
            self._load_module(name, source_file, key)

        if persist:
            with open(os.path.join(self.__code_dir, PERSIST_FILE), "w+") as fd:
                json.dump(mod, fd)

        pkg_resources.working_set = pkg_resources.WorkingSet._build_master()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号