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()
评论列表
文章目录