From dcb8b50b507e696581be7adaf14deda774ef4da7 Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Fri, 9 Feb 2018 23:21:50 +0100 Subject: If available, run 'background' inkscape inside xvfb-run (!201) --- share/extensions/hpgl_encoder.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/share/extensions/hpgl_encoder.py b/share/extensions/hpgl_encoder.py index e8c7a6151..d9a15ef36 100644 --- a/share/extensions/hpgl_encoder.py +++ b/share/extensions/hpgl_encoder.py @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import math import re import string +from distutils.spawn import find_executable from subprocess import Popen, PIPE from shutil import copy2 # local libraries @@ -116,8 +117,13 @@ class hpglEncoder: # so that we can open and close it silently copy2(file, tempfile) + command = 'inkscape --verb=EditSelectAllInAllLayers --verb=EditUnlinkClone --verb=ObjectToPath --verb=FileSave --verb=FileQuit ' + tempfile + + if find_executable('xvfb-run'): + command = 'xvfb-run ' + command + # Unfortunately this briefly pops up the GUI and cannot be done with -z, see https://bugs.launchpad.net/inkscape/+bug/843260 - p = Popen('inkscape --verb=EditSelectAllInAllLayers --verb=EditUnlinkClone --verb=ObjectToPath --verb=FileSave --verb=FileQuit ' + tempfile, shell=True, stdout=PIPE, stderr=PIPE) + p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE) (out, err) = p.communicate() if p.returncode != 0: -- cgit v1.2.3