From 6a23fe868bd58af539c67011b53b1aef72733e0a Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 16 May 2016 22:12:28 -0400 Subject: [PATCH] protect from foot-shooting by printing to stdout --- embroider.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/embroider.py b/embroider.py index bcca7042c..17b29aff8 100644 --- a/embroider.py +++ b/embroider.py @@ -962,6 +962,10 @@ class Embroider(inkex.Effect): process(self.document.getroot()) def effect(self): + # Printing anything other than a valid SVG on stdout blows inkscape up. + old_stdout = sys.stdout + sys.stdout = sys.stderr + self.cache_order() #print >> sys.stderr, "cached stacking order:", self.order @@ -1013,6 +1017,8 @@ class Embroider(inkex.Effect): new_layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer') eo.emit_inkscape(new_layer, emb) + sys.stdout = old_stdout + def emit_inkscape_bbox(self, parent, eo): (x0, y0, x1, y1) = eo.bbox() new_path = [] @@ -1205,7 +1211,8 @@ class Embroider(inkex.Effect): # if they're the same, we don't know which direction # to offset in, so we have to just return the points return pos1, pos2 - print >> sys.stderr, pos1, pos2 + + print pos1, pos2 midpoint = (pos2 + pos1) * 0.5 pos1 = pos1 + (pos1 - midpoint).unit() * offset_px