# HG changeset patch
# User Edouard Tisserant
# Date 1599124568 -7200
# Node ID 889ec6db6f7d3fe3090aeb0e7f152aee7620ae99
# Parent  4ba3bdc7d71f6ca2db18790be3de84a677330ff0
docsvg.py : Better error message when inkscape is not installed.

diff -r 4ba3bdc7d71f -r 889ec6db6f7d 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):