From 0f55fa4f451b0d545c832ac3ae56029079fbb74f Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sun, 15 Aug 2021 13:46:58 +0200 Subject: [PATCH] FactorioClient: allow setting a folder and find the executable in it, instead of trying to run a folder. --- FactorioClient.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/FactorioClient.py b/FactorioClient.py index cfb59528..caf0f21f 100644 --- a/FactorioClient.py +++ b/FactorioClient.py @@ -354,13 +354,13 @@ if __name__ == '__main__': factorio_server_logger = logging.getLogger("FactorioServer") options = Utils.get_options() executable = options["factorio_options"]["executable"] - bin_dir = os.path.dirname(executable) - if not os.path.exists(bin_dir): - raise FileNotFoundError(f"Path {bin_dir} does not exist or could not be accessed.") - if not os.path.isdir(bin_dir): - raise NotADirectoryError(f"Path {bin_dir} is not a directory.") - if not os.path.exists(executable): - if os.path.exists(executable + ".exe"): + + if not os.path.exists(os.path.dirname(executable)): + raise FileNotFoundError(f"Path {os.path.dirname(executable)} does not exist or could not be accessed.") + if os.path.isdir(executable): # user entered a path to a directory, let's find the executable therein + executable = os.path.join(executable, "factorio") + if not os.path.isfile(executable): + if os.path.isfile(executable + ".exe"): executable = executable + ".exe" else: raise FileNotFoundError(f"Path {executable} is not an executable file.")