- lyx2lyx_cmd = 'python "%s" "%s"' % (lyx2lyx, curfile)
- l2l_status, l2l_stdout = run_cmd(lyx2lyx_cmd)
- if l2l_status != None:
- error('%s failed to convert "%s"' % (lyx2lyx, curfile))
- if l2l_stdout.startswith("\x1f\x8b"):
- l2l_stdout = gzip.GzipFile("", "r", 0, StringIO(l2l_stdout)).read()
+ try:
+ l2l_stdout = subprocess.check_output([PYTHON_BIN, lyx2lyx, curfile])
+ except subprocess.CalledProcessError:
+ error('%s failed to convert "%s"' % (lyx2lyx, tostr(curfile)))
+ if l2l_stdout.startswith(b"\x1f\x8b"):
+ l2l_stdout = gzip.GzipFile("", "rb", 0, BytesIO(l2l_stdout)).read()
+ elif running_on_windows:
+ # For some unknown reason, there can be a spurious '\r' in the line
+ # separators, causing spurious empty lines when calling splitlines.
+ l2l_stdout = l2l_stdout.replace('\r\r\n', '\r\n')