kopia lustrzana https://github.com/inkstitch/inkstitch
fix issue with input plugin
rodzic
4c46c2eec1
commit
b674c192ee
|
@ -14,6 +14,7 @@ from ..svg import PIXELS_PER_MM, render_stitch_plan
|
|||
from ..svg.tags import INKSCAPE_LABEL
|
||||
from ..i18n import _
|
||||
from ..stitch_plan import StitchPlan
|
||||
from ..utils.io import save_stdout
|
||||
|
||||
|
||||
class Input(object):
|
||||
|
@ -25,6 +26,9 @@ class Input(object):
|
|||
|
||||
|
||||
def affect(self, args):
|
||||
# libembroidery likes to dump a bunch of debugging stuff to stdout
|
||||
save_stdout()
|
||||
|
||||
embroidery_file = args[0]
|
||||
pattern = embPattern_create()
|
||||
embPattern_read(pattern, embroidery_file)
|
||||
|
@ -65,4 +69,4 @@ class Input(object):
|
|||
# Note: this is NOT the same as centering the design in the canvas!
|
||||
layer.set('transform', 'translate(%s,%s)' % (extents[0], extents[1]))
|
||||
|
||||
print etree.tostring(svg)
|
||||
print >> sys.real_stdout, etree.tostring(svg)
|
||||
|
|
|
@ -9,15 +9,13 @@ def save_stderr():
|
|||
sys.stderr_dup = os.dup(sys.stderr.fileno())
|
||||
sys.real_stderr = os.fdopen(sys.stderr_dup, 'w')
|
||||
os.dup2(null.fileno(), 2)
|
||||
sys.stderr_backup = sys.stderr
|
||||
sys.stderr = StringIO()
|
||||
|
||||
|
||||
def restore_stderr():
|
||||
sys.real_stderr.close()
|
||||
os.dup2(sys.stderr_dup, 2)
|
||||
sys.real_stderr.write(sys.stderr.getvalue())
|
||||
sys.stderr = sys.stderr_backup
|
||||
sys.stderr = sys.real_stderr
|
||||
|
||||
# It's probably possible to generalize this code, but when I tried,
|
||||
# the result was incredibly unreadable.
|
||||
|
@ -26,12 +24,10 @@ def save_stdout():
|
|||
sys.stdout_dup = os.dup(sys.stdout.fileno())
|
||||
sys.real_stdout = os.fdopen(sys.stdout_dup, 'w')
|
||||
os.dup2(null.fileno(), 1)
|
||||
sys.stdout_backup = sys.stdout
|
||||
sys.stdout = StringIO()
|
||||
|
||||
|
||||
def restore_stdout():
|
||||
sys.real_stdout.close()
|
||||
os.dup2(sys.stdout_dup, 1)
|
||||
sys.real_stdout.write(sys.stdout.getvalue())
|
||||
sys.stdout = sys.stdout_backup
|
||||
sys.stdout = sys.real_stdout
|
||||
|
|
Ładowanie…
Reference in New Issue