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()
|
||||
|
||||
|
||||
@@ -123,7 +123,6 @@ async def get_or_create_set_score(tune_set: playlists.Set) -> playlists.SetScore
|
||||
# No score exists, so we need to create it
|
||||
set_source = lilypond_source.set_source(tune_set=lilypond_set)
|
||||
out_filepath = files_service.get_set_filename(set_score_hash)
|
||||
print("Out filepath: ", str(out_filepath))
|
||||
async with files_service.tmp_file(content=set_source) as source_filepath:
|
||||
if not pdf_filepath.exists():
|
||||
pdf_result = await lilypond_render.render_file(
|
||||
|
||||
Reference in New Issue
Block a user