# HG changeset patch # User Edouard Tisserant # Date 1599124568 -7200 # Node ID ffce85221ea5b85d7e80b605f3b222fa3e2f8050 # Parent 44dd48070e4164c370ad5688fbd4e49b3b30b6d9 SVGHMI: Better error message when inkscape is not installed. diff -r 44dd48070e41 -r ffce85221ea5 docutil/docsvg.py --- a/docutil/docsvg.py Wed Sep 02 11:45:41 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): diff -r 44dd48070e41 -r ffce85221ea5 svghmi/svghmi.py --- a/svghmi/svghmi.py Wed Sep 02 11:45:41 2020 +0200 +++ b/svghmi/svghmi.py Thu Sep 03 11:16:08 2020 +0200 @@ -485,13 +485,17 @@ InkscapeGeomColumns = ["Id", "x", "y", "w", "h"] inkpath = get_inkscape_path() + + if inkpath is None: + self.FatalError("SVGHMI: inkscape is not installed.") + svgpath = self._getSVGpath() status, result, _err_result = ProcessLogger(self.GetCTRoot().logger, '"' + inkpath + '" -S "' + svgpath + '"', no_stdout=True, no_stderr=True).spin() if status != 0: - self.FatalError("SVGHMI : inkscape couldn't extract geometry from given SVG") + self.FatalError("SVGHMI: inkscape couldn't extract geometry from given SVG.") res = [] for line in result.split():