Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

fix crash when dirpath contains special character #96

Merged
merged 2 commits into from
Sep 4, 2018
Merged
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
11 changes: 10 additions & 1 deletion bin/autodiscover.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
_quiet = None


try:
_glob_escape = glob.escape
except AttributeError:
# Python <3.4
def _glob_escape(pathname):
pat = re.compile(r'([[?*])')
return pat.sub(r'[\1]', pathname)


def printv(s):
if _verbose:
sys.stderr.write(s + "\n")
Expand Down Expand Up @@ -78,7 +87,7 @@ def list_mpiexec(dirpath):
* Otherwise, one is randomly chosen
"""

lst = glob.glob(os.path.join(dirpath, 'bin', '*mpiexec*'))
lst = glob.glob(os.path.join(_glob_escape(dirpath), 'bin', '*mpiexec*'))
link_rel = {}

# As an exception, we need to exclude binaries like
Expand Down