From 1d7cb76dd0422e0e13d0933dd835384a31d22732 Mon Sep 17 00:00:00 2001 From: Mario Voigt Date: Sat, 25 Dec 2021 20:47:58 +0100 Subject: [PATCH] fix deprecation in inkcut --- extensions/fablabchemnitz/inkcut/inkcut.py | 3 +-- extensions/fablabchemnitz/inkcut/inkcut_cut.py | 5 +++++ extensions/fablabchemnitz/inkcut/inkcut_open.py | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/extensions/fablabchemnitz/inkcut/inkcut.py b/extensions/fablabchemnitz/inkcut/inkcut.py index 13d009a6..56831c12 100644 --- a/extensions/fablabchemnitz/inkcut/inkcut.py +++ b/extensions/fablabchemnitz/inkcut/inkcut.py @@ -25,7 +25,6 @@ import inkex from lxml import etree from subprocess import Popen, PIPE from shutil import copy2 -from distutils.spawn import find_executable def contains_text(nodes): for node in nodes: @@ -42,7 +41,7 @@ def convert_objects_to_paths(file, document): command = "inkscape " + tempfile + ' --actions="EditSelectAllInAllLayers;EditUnlinkClone;ObjectToPath;FileSave;FileQuit"' - if find_executable('xvfb-run'): + if shutil.which('xvfb-run'): command = 'xvfb-run -a ' + command p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE) diff --git a/extensions/fablabchemnitz/inkcut/inkcut_cut.py b/extensions/fablabchemnitz/inkcut/inkcut_cut.py index 8203b635..54090480 100644 --- a/extensions/fablabchemnitz/inkcut/inkcut_cut.py +++ b/extensions/fablabchemnitz/inkcut/inkcut_cut.py @@ -24,6 +24,7 @@ import os import sys import inkex +import shutil from lxml import etree import subprocess from inkcut import contains_text, convert_objects_to_paths @@ -58,6 +59,10 @@ class InkscapeInkcutPlugin(inkex.Effect): cmd = [python, inkcut] else: cmd = ['inkcut'] + + if shutil.which('inkcut') is None: + inkex.errormsg("Error: inkcut executable not found!") + return cmd += ['open', '-', '--nodes']+[str(k) for k in nodes.keys()] diff --git a/extensions/fablabchemnitz/inkcut/inkcut_open.py b/extensions/fablabchemnitz/inkcut/inkcut_open.py index 8024f108..b1481939 100644 --- a/extensions/fablabchemnitz/inkcut/inkcut_open.py +++ b/extensions/fablabchemnitz/inkcut/inkcut_open.py @@ -25,6 +25,7 @@ import os import sys import inkex import importlib +import shutil import subprocess from lxml import etree from inkcut import convert_objects_to_paths @@ -50,6 +51,10 @@ class InkscapeInkcutPlugin(inkex.Effect): else: cmd = ['inkcut'] + if shutil.which('inkcut') is None: + inkex.errormsg("Error: inkcut executable not found!") + return + document = convert_objects_to_paths(self.options.input_file, self.document) cmd += ['open', '-']