add functionality for async generation to MultiMystery.py

This commit is contained in:
Fabian Dill
2020-11-08 07:26:50 +01:00
parent 1a32d45474
commit 27971ee6a9
2 changed files with 25 additions and 8 deletions

View File

@@ -46,6 +46,7 @@ if __name__ == "__main__":
output_path = options["general_options"]["output_path"]
enemizer_path = multi_mystery_options["enemizer_path"]
player_files_path = multi_mystery_options["player_files_path"]
target_player_count = multi_mystery_options.get("players", 0)
race = multi_mystery_options["race"]
create_spoiler = multi_mystery_options["create_spoiler"]
zip_roms = multi_mystery_options["zip_roms"]
@@ -56,6 +57,7 @@ if __name__ == "__main__":
#zip_password = multi_mystery_options["zip_password"] not at this time
player_name = multi_mystery_options["player_name"]
meta_file_path = multi_mystery_options["meta_file_path"]
weights_file_path = multi_mystery_options.get("weights_file_path", "weights.yaml")
teams = multi_mystery_options["teams"]
rom_file = options["general_options"]["rom_file"]
host = options["server_options"]["host"]
@@ -72,14 +74,9 @@ if __name__ == "__main__":
os.makedirs(player_files_path, exist_ok=True)
for file in os.listdir(player_files_path):
lfile = file.lower()
if lfile.endswith(".yaml") and lfile != meta_file_path.lower():
if lfile.endswith(".yaml") and lfile != meta_file_path.lower() and lfile != weights_file_path.lower():
player_files.append(file)
print(f"Found player's file {file}.")
player_count = len(player_files)
if player_count == 0:
feedback(f"No player files found. Please put them in a {player_files_path} folder.")
else:
print(player_count, "Players found.")
player_string = ""
for i, file in enumerate(player_files, 1):
@@ -93,7 +90,20 @@ if __name__ == "__main__":
else:
basemysterycommand = f"py -{py_version} Mystery.py" # source
command = f"{basemysterycommand} --multi {len(player_files)} {player_string} " \
weights_file_path = os.path.join(player_files_path, weights_file_path)
if os.path.exists(weights_file_path):
target_player_count = max(len(player_files), target_player_count)
else:
target_player_count = len(player_files)
if target_player_count == 0:
feedback(f"No player files found. Please put them in a {player_files_path} folder.")
else:
print(target_player_count, "Players found.")
command = f"{basemysterycommand} --multi {target_player_count} {player_string} " \
f"--rom \"{rom_file}\" --enemizercli \"{enemizer_path}\" " \
f"--outputpath \"{output_path}\" --teams {teams}"
@@ -107,6 +117,8 @@ if __name__ == "__main__":
command += " --race"
if os.path.exists(os.path.join(player_files_path, meta_file_path)):
command += f" --meta {os.path.join(player_files_path, meta_file_path)}"
if os.path.exists(weights_file_path):
command += f" --weights {weights_file_path}"
print(command)
import time