Есть такой код:
print("svg_samples_list:\n" + str(svg_samples_list) + '\n')
ink_proc = subprocess.Popen(['inkscape', '--shell'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE)
def get_data_about_svgfile (svgfile):
o = ink_proc.communicate("-S " + svgfile + "\n")
print(svgfile + ":\n" + o[0] + "\n")
map(get_data_about_svgfile, svg_samples_list)
ink_proc.communicate("quit\n")
работа скрипта:
$ python2 generate-bitmap-samples.py
svg_samples_list:
[u'./tmp/star0.svg', u'./tmp/star0.rot.svg', u'./tmp/star0.rot_ref.svg', u'./tmp/star0.rot_ref_flat.svg']
./tmp/star0.svg:
Inkscape 0.91 r13725 interactive shell mode. Type 'quit' to quit.
>svg2,48.365724,-1282.3207,158.90038,152.83165
layer1,48.365724,-1282.3207,158.90038,152.83165
path3336,48.365724,-1282.3207,158.90038,152.83165
>
Traceback (most recent call last):
File "generate-bitmap-samples.py", line 100, in <module>
map(get_data_about_svgfile, svg_samples_list)
File "generate-bitmap-samples.py", line 97, in get_data_about_svgfile
o = ink_proc.communicate("-S " + svgfile + "\n")
File "/usr/lib/python2.7/subprocess.py", line 799, in communicate
return self._communicate(input)
File "/usr/lib/python2.7/subprocess.py", line 1404, in _communicate
self.stdin.flush()
ValueError: I/O operation on closed file
Нужна помощь в работе с внешними процессами, короче.