fix multiapps bug : "26660ad1-6ebb-4f59-8cba-a8432dfe8d38"

This commit is contained in:
Jason Lee
2024-03-09 14:03:26 +08:00
parent 62b3b2390d
commit 6ea3dd856f
2 changed files with 13 additions and 5 deletions

View File

@@ -86,23 +86,29 @@ def get_vm_file(env, config: Dict[str, Any]) -> Union[Optional[str], List[Option
if not config.get("multi", False):
paths: List[str] = [config["path"]]
dests: List[str] = [config["dest"]]
else:
paths: List[str] = config["path"]
dests: List[str] = config["dest"]
print(config)
if "time_suffix" in config.keys() and config["time_suffix"]:
if "time_format" in config.keys():
time_format = config["time_format"]
# Insert time before . in file type suffix
paths = [p.split(".")[0] + datetime.now().strftime(time_format) + "." + p.split(".")[1] if "." in p else p for p in paths]
dests = [d.split(".")[0] + datetime.now().strftime(time_format) + "." + d.split(".")[1] if "." in d else d for d in dests]
else:
paths: List[str] = config["path"]
dests: List[str] = config["dest"]
print(paths)
print(dests)
cache_paths: List[str] = []
gives: Set[int] = set(config.get("gives", [0]))
for i, (p, d) in enumerate(zip(paths, dests)):
print("env cache_dir: ")
print(env.cache_dir)
_path = os.path.join(env.cache_dir, d)
print("_path: ")
print(_path)
file = env.controller.get_file(p)
if file is None:
#return None
@@ -116,6 +122,7 @@ def get_vm_file(env, config: Dict[str, Any]) -> Union[Optional[str], List[Option
with open(_path, "wb") as f:
f.write(file)
# debug
print("cache_paths")
print(cache_paths)
return cache_paths[0] if len(cache_paths)==1 else cache_paths