]> git.lyx.org Git - lyx.git/commitdiff
Fix instant preview on windows when dvipng is not available.
authorEnrico Forestieri <forenr@lyx.org>
Sun, 28 Nov 2010 01:22:36 +0000 (01:22 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Sun, 28 Nov 2010 01:22:36 +0000 (01:22 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36545 a592a061-630c-0410-9148-cb99ea01b6c8

lib/scripts/lyxpreview_tools.py

index 73dbc9a1f46cb8bf572869b1a300f2d573fbb9f9..5acaec79b99c161e41671736eaf053fe7e65feab 100644 (file)
@@ -60,19 +60,20 @@ def make_texcolor(hexcolor, graphics):
 
 
 def find_exe(candidates, path):
+    extlist = ['']
+    if os.environ.has_key("PATHEXT"):
+        extlist = extlist + os.environ["PATHEXT"].split(os.pathsep)
+
     for prog in candidates:
         for directory in path:
-            if os.name == "nt":
-                full_path = os.path.join(directory, prog + ".exe")
-            else:
-                full_path = os.path.join(directory, prog)
-
-            if os.access(full_path, os.X_OK):
-                # The thing is in the PATH already (or we wouldn't
-                # have found it). Return just the basename to avoid
-                # problems when the path to the executable contains
-                # spaces.
-                return os.path.basename(full_path)
+            for ext in extlist:
+                full_path = os.path.join(directory, prog + ext)
+                if os.access(full_path, os.X_OK):
+                    # The thing is in the PATH already (or we wouldn't
+                    # have found it). Return just the basename to avoid
+                    # problems when the path to the executable contains
+                    # spaces.
+                    return os.path.basename(full_path)
 
     return None