docsvg.py : Better error message when inkscape is not installed.
authorEdouard Tisserant
Thu, 03 Sep 2020 11:16:08 +0200
changeset 2705 889ec6db6f7d
parent 2704 4ba3bdc7d71f
child 2706 65f35ac97cd6
docsvg.py : Better error message when inkscape is not installed.
docutil/docsvg.py
--- a/docutil/docsvg.py	Sat Apr 04 09:41:32 2020 +0200
+++ b/docutil/docsvg.py	Thu Sep 03 11:16:08 2020 +0200
@@ -34,16 +34,23 @@
     if wx.Platform == '__WXMSW__':
         from six.moves import winreg
         try:
-            svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
-                                           'Software\\Classes\\svgfile\\shell\\Inkscape\\command')
+                svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
+                                               'Software\\Classes\\svgfile\\shell\\Inkscape\\command')
         except OSError:
-            svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
-                                           'Software\\Classes\\inkscape.svg\\shell\\open\\command')
+            try:
+                svgexepath = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE,
+                                               'Software\\Classes\\inkscape.svg\\shell\\open\\command')
+            except Exception:
+                return None
+
         svgexepath = svgexepath.replace('"%1"', '').strip()
         return svgexepath.replace('"', '')
     else:
-        # TODO: search path
-        return os.path.join("/usr/bin", "inkscape")
+        # TODO: search for inkscape in $PATH
+        svgexepath = os.path.join("/usr/bin", "inkscape")
+        if os.path.exists(svgexepath):
+            return svgexepath
+        return None
 
 
 def open_win_svg(svgexepath, svgfile):