Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions autosub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down