Prioritize path_extension in which method
authorTomás Touceda <chiiph@leap.se>
Wed, 20 Mar 2013 12:31:27 +0000 (09:31 -0300)
committerTomás Touceda <chiiph@leap.se>
Wed, 20 Mar 2013 12:31:27 +0000 (09:31 -0300)
changes/feature_improve_which [new file with mode: 0644]
src/leap/common/files.py

diff --git a/changes/feature_improve_which b/changes/feature_improve_which
new file mode 100644 (file)
index 0000000..d1d1fb5
--- /dev/null
@@ -0,0 +1,2 @@
+  o Prioritize the path_extension in the which method so it finds our bundled
+    app before the system one, if any.
index 9b80236..e3c8423 100644 (file)
@@ -112,7 +112,7 @@ def which(name, flags=os.X_OK, path_extension="/usr/sbin:/sbin"):
     result = []
     exts = filter(None, os.environ.get('PATHEXT', '').split(os.pathsep))
     path = os.environ.get('PATH', None)
-    path += ":" + path_extension
+    path = path_extension + os.pathsep + path
     if path is None:
         return []
     parts = path.split(os.pathsep)