Fix xcursorgen generating incorrect output to stdout

This commit is contained in:
Quantum 2020-09-26 18:50:29 -04:00
parent 0391d63e5e
commit a9b6711228

View file

@ -40,10 +40,15 @@ def to_x11(frames: List[CursorFrame]) -> bytes:
image.save(filename=os.path.join(png_dir, name)) image.save(filename=os.path.join(png_dir, name))
counter += 1 counter += 1
process = subprocess.Popen(['xcursorgen', '-p', png_dir], stdin=subprocess.PIPE, stdout=subprocess.PIPE) output_file = os.path.join(png_dir, 'cursor')
result, error = process.communicate('\n'.join(configs).encode(sys.getfilesystemencoding())) process = subprocess.Popen(['xcursorgen', '-p', png_dir, '-', output_file], stdin=subprocess.PIPE,
stderr=subprocess.PIPE)
if error: _, error = process.communicate('\n'.join(configs).encode(sys.getfilesystemencoding()))
if process.wait() != 0:
raise RuntimeError('xcursorgen failed: %r' % error) raise RuntimeError('xcursorgen failed: %r' % error)
with open(output_file, 'rb') as f:
result = f.read()
return result return result