summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2019-09-27 00:06:40 +0200
committerjaseg <git@jaseg.net>2019-09-27 10:04:41 +0200
commit3340885ade322e8ae6b75257cc760ff48e218a0a (patch)
treee42eddc237135eec9a438abda7cd86dc5c6d98dd /support
parent1f13910211d99e45118b1efc897007772c6d51d7 (diff)
downloadpogojig-3340885ade322e8ae6b75257cc760ff48e218a0a.tar.gz
pogojig-3340885ade322e8ae6b75257cc760ff48e218a0a.tar.bz2
pogojig-3340885ade322e8ae6b75257cc760ff48e218a0a.zip
Made the inkscape exporter headless
Diffstat (limited to 'support')
-rwxr-xr-xsupport/inkscape_exporter.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/support/inkscape_exporter.py b/support/inkscape_exporter.py
index 4e80c63..25fcabe 100755
--- a/support/inkscape_exporter.py
+++ b/support/inkscape_exporter.py
@@ -6,6 +6,8 @@ import tempfile
from pogojig.inkscape import effect, inkscape
+from xvfbwrapper import Xvfb
+
def _unfuck_svg_document(temp_svg_path):
"""
@@ -45,17 +47,19 @@ if __name__ == '__main__':
parser.add_argument('infile', metavar='input.svg', help='Inkscape SVG input file')
parser.add_argument('outfile', metavar='output.dxf', help='DXF output file')
args = parser.parse_args()
-
- effect.ExportEffect.check_document_units(args.infile)
-
- with tempfile.TemporaryDirectory() as tmpdir:
- temp_svg_path = os.path.join(tmpdir, os.path.basename(args.infile))
- shutil.copyfile(args.infile, temp_svg_path)
-
- _unfuck_svg_document(temp_svg_path)
-
- export_effect = effect.ExportEffect()
- export_effect.affect(args=[temp_svg_path], output=False)
-
- with open(args.outfile, 'w') as f:
- export_effect.write_dxf(f)
+
+ with Xvfb():
+ effect.ExportEffect.check_document_units(args.infile)
+
+ with tempfile.TemporaryDirectory() as tmpdir:
+ temp_svg_path = os.path.join(tmpdir, os.path.basename(args.infile))
+ shutil.copyfile(args.infile, temp_svg_path)
+
+ _unfuck_svg_document(temp_svg_path)
+
+ export_effect = effect.ExportEffect()
+ export_effect.affect(args=[temp_svg_path], output=False)
+
+ with open(args.outfile, 'w') as f:
+ export_effect.write_dxf(f)
+