Fix set score rendering
This commit is contained in:
@@ -78,20 +78,26 @@ async def render_file(
|
||||
stderr=asyncio.subprocess.PIPE,
|
||||
)
|
||||
|
||||
_stdout, stderr = await proc.communicate()
|
||||
stdout, stderr = await proc.communicate()
|
||||
|
||||
if proc.returncode:
|
||||
logger.warning(f"Lilypond process failed with return code: {proc.returncode}")
|
||||
log_stream(stdout, "stdout")
|
||||
log_stream(stderr, "stderr")
|
||||
errors = await _build_errors(input_file=input_file, stderr=stderr)
|
||||
return Result(error=errors)
|
||||
|
||||
return Result(result=output_file)
|
||||
|
||||
|
||||
def log_stream(stream: bytes, name: str):
|
||||
stream_lines = stream.decode("utf-8").splitlines()
|
||||
for line in stream_lines:
|
||||
logger.warning(f"[Lilypond {name}] {line}")
|
||||
|
||||
|
||||
async def _build_errors(input_file: Path, stderr: bytes) -> list[RenderError]:
|
||||
stderr_lines = stderr.decode("utf-8").splitlines()
|
||||
logger.warning("Lilypond errors:")
|
||||
for line in stderr_lines:
|
||||
logger.warning(f"[LILYPOND] {line}")
|
||||
async with aiofiles.open(input_file, "r") as f:
|
||||
lines = await f.readlines()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user