diff --git a/autosub/__init__.py b/autosub/__init__.py index f4adee137..5978b58d5 100644 --- a/autosub/__init__.py +++ b/autosub/__init__.py @@ -155,17 +155,26 @@ def is_exe(file_path): Checks whether a file is executable. """ return os.path.isfile(file_path) and os.access(file_path, os.X_OK) - + # necessary to run on Windows + if os.name == "nt": + program += ".exe" fpath, _ = os.path.split(program) if fpath: if is_exe(program): return program else: - for path in os.environ["PATH"].split(os.pathsep): - path = path.strip('"') - exe_file = os.path.join(path, program) - if is_exe(exe_file): - return exe_file + # looks for program file in the script execution folder + # before checking on system path + script_dir = os.getcwd() + local_program = os.path.join(script_dir, program) + if is_exe(local_program): + return local_program + else: + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + exe_file = os.path.join(path, program) + if is_exe(exe_file): + return exe_file return None