summaryrefslogtreecommitdiff
path: root/compressor/utils
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-05-11 13:31:59 +0200
committerJannis Leidel <jannis@leidel.info>2011-05-11 13:52:35 +0200
commit049583f7d54d552e77abfb8bdf11afa14f744a0e (patch)
tree87859de3d682ce0f99d2d7536fa7c54a09169e72 /compressor/utils
parentf0cdbf3f6a4e7bc22254665258571f687652aecf (diff)
downloaddjango-compressor-049583f7d54d552e77abfb8bdf11afa14f744a0e.tar.gz
Fixed PATH handling on windows.
Diffstat (limited to 'compressor/utils')
-rw-r--r--compressor/utils/__init__.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/compressor/utils/__init__.py b/compressor/utils/__init__.py
index 699e37d..766943c 100644
--- a/compressor/utils/__init__.py
+++ b/compressor/utils/__init__.py
@@ -59,17 +59,25 @@ def walk(root, topdown=True, onerror=None, followlinks=False):
yield (link_dirpath, link_dirnames, link_filenames)
+def get_pathext(default_pathext=None):
+ """
+ Returns the path extensions from environment or a default
+ """
+ if default_pathext is None:
+ default_pathext = os.pathsep.join(['.COM', '.EXE', '.BAT', '.CMD'])
+ return os.environ.get('PATHEXT', default_pathext)
+
def find_command(cmd, paths=None, pathext=None):
"""
Searches the PATH for the given command and returns its path
"""
if paths is None:
- paths = os.environ.get('PATH', []).split(os.pathsep)
+ paths = os.environ.get('PATH', '').split(os.pathsep)
if isinstance(paths, basestring):
paths = [paths]
# check if there are funny path extensions for executables, e.g. Windows
if pathext is None:
- pathext = os.environ.get('PATHEXT', '.COM;.EXE;.BAT;.CMD')
+ pathext = get_pathext()
pathext = [ext for ext in pathext.lower().split(os.pathsep)]
# don't use extensions if the command ends with one of them
if os.path.splitext(cmd)[1].lower() in pathext: