diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/exceptions.py | 30 | ||||
| -rw-r--r-- | lib/extensions/print_pdf.py | 2 | ||||
| -rw-r--r-- | lib/svg/rendering.py | 2 |
3 files changed, 31 insertions, 3 deletions
diff --git a/lib/exceptions.py b/lib/exceptions.py index 3a6b456c..8bef185f 100644 --- a/lib/exceptions.py +++ b/lib/exceptions.py @@ -3,12 +3,38 @@ # Copyright (c) 2010 Authors # Licensed under the GNU GPL version 3.0 or later. See the file LICENSE for details. import traceback +import sys +import platform +import subprocess +from glob import glob class InkstitchException(Exception): pass +def get_os_version(): + if sys.platform == "win32": + # To get the windows version, python functions are used + # Using python subprocess with cmd.exe in windows is currently a security risk + os_ver = "Windows " + platform.release() + " version: " + platform.version() + if sys.platform == "darwin": + # macOS command line progam provides accurate info than python functions + mac_v = subprocess.run(["sw_vers"], capture_output=True, text=True) + os_ver = str(mac_v.stdout.strip()) + if sys.platform == "linux": + # Getting linux version method used here is for systemd and nonsystemd linux. + try: + ltmp = subprocess.run(["cat"] + glob("/etc/*-release"), capture_output=True, text=True) + lnx_ver = ltmp.stdout.splitlines() + lnx_ver = str(list(filter(lambda x: "PRETTY_NAME" in x, lnx_ver))) + os_ver = lnx_ver[15:][:-3] + except FileNotFoundError: + os_ver = "Cannot get Linux distro version" + + return os_ver + + def format_uncaught_exception(): """Format the current exception as a request for a bug report. @@ -30,7 +56,9 @@ def format_uncaught_exception(): "- create a new issue at") message += " https://github.com/inkstitch/inkstitch/issues/new\n\n" message += _("Include the error description and also (if possible) the svg file.") - message += '\n\n\n' + message += '\n\n' + message += get_os_version() + message += '\n\n' message += version.get_inkstitch_version() + '\n' message += traceback.format_exc() diff --git a/lib/extensions/print_pdf.py b/lib/extensions/print_pdf.py index 4e667130..ddfdc3a3 100644 --- a/lib/extensions/print_pdf.py +++ b/lib/extensions/print_pdf.py @@ -231,7 +231,7 @@ class Print(InkstitchExtension): # for all color blocks together. layers = svg.findall("./g[@%s='layer']" % INKSCAPE_GROUPMODE) - stitch_plan_layer = svg.find(".//*[@id='__inkstitch_stitch_plan__']") + stitch_plan_layer = svg.findone(".//*[@id='__inkstitch_stitch_plan__']") # Make sure there is no leftover translation from stitch plan preview stitch_plan_layer.pop('transform') diff --git a/lib/svg/rendering.py b/lib/svg/rendering.py index 1f74e2df..b96fe9b7 100644 --- a/lib/svg/rendering.py +++ b/lib/svg/rendering.py @@ -222,7 +222,7 @@ def color_block_to_paths(color_block, svg, destination, visual_commands): def render_stitch_plan(svg, stitch_plan, realistic=False, visual_commands=True): - layer = svg.find(".//*[@id='__inkstitch_stitch_plan__']") + layer = svg.findone(".//*[@id='__inkstitch_stitch_plan__']") if layer is None: layer = inkex.Group(attrib={ 'id': '__inkstitch_stitch_plan__', |
