Fix set score rendering
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,128 +0,0 @@
|
|||||||
from folkugat_web.model import IndexedList, playlists
|
|
||||||
from folkugat_web.model import temes as model
|
|
||||||
|
|
||||||
TEMES = [
|
|
||||||
# ---
|
|
||||||
model.Tema(
|
|
||||||
title="El Joan Petit",
|
|
||||||
hidden=False,
|
|
||||||
).with_ngrams(),
|
|
||||||
# ---
|
|
||||||
model.Tema(
|
|
||||||
title="Pasdoble de Muntanya (Cançó amb el nom molt llarg)",
|
|
||||||
links=IndexedList([
|
|
||||||
model.Link(
|
|
||||||
id=0,
|
|
||||||
content_type=model.ContentType.AUDIO,
|
|
||||||
link_type=model.LinkType.SPOTIFY,
|
|
||||||
url="https://open.spotify.com/track/4j9Krf19c5USmMvVUCoeWa?si=3023d1d83f814886",
|
|
||||||
title="Versió de l'Orquestrina Trama",
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
hidden=False,
|
|
||||||
).with_ngrams(),
|
|
||||||
# ---
|
|
||||||
model.Tema(
|
|
||||||
title="Astrid Waltz",
|
|
||||||
alternatives=["vals"],
|
|
||||||
links=IndexedList([
|
|
||||||
model.Link(
|
|
||||||
id=0,
|
|
||||||
content_type=model.ContentType.OTHER,
|
|
||||||
link_type=None,
|
|
||||||
url="https://marc.sastre.cat/folkugat",
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
hidden=False,
|
|
||||||
).with_ngrams(),
|
|
||||||
# ---
|
|
||||||
model.Tema(
|
|
||||||
title="Ook Pik Waltz",
|
|
||||||
alternatives=["vals"],
|
|
||||||
hidden=False,
|
|
||||||
).with_ngrams(),
|
|
||||||
# ---
|
|
||||||
model.Tema(
|
|
||||||
title="Pasdoble Patumaire",
|
|
||||||
hidden=False,
|
|
||||||
).with_ngrams(),
|
|
||||||
# ---
|
|
||||||
model.Tema(
|
|
||||||
title="El Gitano",
|
|
||||||
links=IndexedList([
|
|
||||||
model.Link(
|
|
||||||
id=0,
|
|
||||||
content_type=model.ContentType.PARTITURA,
|
|
||||||
link_type=model.LinkType.PDF,
|
|
||||||
url="/db/temes/1/tema.pdf",
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
hidden=False,
|
|
||||||
).with_ngrams(),
|
|
||||||
# ---
|
|
||||||
model.Tema(
|
|
||||||
title="Pasdoble de Gitanes",
|
|
||||||
alternatives=["entrada"],
|
|
||||||
hidden=False,
|
|
||||||
).with_ngrams(),
|
|
||||||
# ---
|
|
||||||
model.Tema(
|
|
||||||
title="Jota Comunera",
|
|
||||||
hidden=False,
|
|
||||||
).with_ngrams(),
|
|
||||||
# ---
|
|
||||||
model.Tema(
|
|
||||||
title="Malaguenya de Barxeta",
|
|
||||||
lyrics=IndexedList([
|
|
||||||
model.Lyrics(
|
|
||||||
id=0,
|
|
||||||
title="Malaguenya de Barxeta",
|
|
||||||
content="""
|
|
||||||
Mira si he corregut terres
|
|
||||||
que he estat en Alfarrasí,
|
|
||||||
en Adzaneta i Albaida,
|
|
||||||
en el Palomar i ací.
|
|
||||||
|
|
||||||
Omplim el sarró de pa,
|
|
||||||
si vols que et guarde les cabres,
|
|
||||||
que les figues ja s'acaben
|
|
||||||
i raïm ja no hi ha.
|
|
||||||
|
|
||||||
L'altre dia jo somiava
|
|
||||||
que ja era realitat
|
|
||||||
un món sense violència
|
|
||||||
ple de pau i llibertat.
|
|
||||||
|
|
||||||
Vinc del cor de la Costera,
|
|
||||||
el poble dels socarrats,
|
|
||||||
d'allà on renaix de les cendres
|
|
||||||
el meu País Valencià.
|
|
||||||
""".strip(),
|
|
||||||
),
|
|
||||||
]),
|
|
||||||
properties=IndexedList([
|
|
||||||
model.Property(
|
|
||||||
id=0,
|
|
||||||
field=model.PropertyField.AUTOR,
|
|
||||||
value="Pep Jimeno 'Botifarra'"
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
hidden=False,
|
|
||||||
).with_ngrams(),
|
|
||||||
]
|
|
||||||
|
|
||||||
PLAYLIST_ENTRIES = [
|
|
||||||
playlists.PlaylistEntry(0, 2, 0, 1),
|
|
||||||
playlists.PlaylistEntry(1, 2, 0, 2),
|
|
||||||
playlists.PlaylistEntry(2, 2, 1, 3),
|
|
||||||
playlists.PlaylistEntry(3, 2, 2, 4),
|
|
||||||
playlists.PlaylistEntry(4, 2, 2, 5),
|
|
||||||
playlists.PlaylistEntry(5, 2, 2, 6),
|
|
||||||
playlists.PlaylistEntry(6, 2, 3, 7),
|
|
||||||
playlists.PlaylistEntry(7, 2, 4, 8),
|
|
||||||
]
|
|
||||||
|
|
||||||
PLAYLIST = playlists.Playlist.from_playlist_entries(
|
|
||||||
session_id=2,
|
|
||||||
entries=PLAYLIST_ENTRIES,
|
|
||||||
)
|
|
||||||
@@ -27,9 +27,9 @@ async def lifespan(_: FastAPI):
|
|||||||
directories.STATIC_DIR / "css" / "main.css",
|
directories.STATIC_DIR / "css" / "main.css",
|
||||||
# "--minify"
|
# "--minify"
|
||||||
])
|
])
|
||||||
|
log.logger.info("Tailwind CSS done")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.logger.error(f"Error running tailwindcss: {e}")
|
log.logger.error(f"Error running tailwindcss: {e}")
|
||||||
log.logger.info("Tailwind CSS done")
|
|
||||||
|
|
||||||
log.logger.info("Creating DB...")
|
log.logger.info("Creating DB...")
|
||||||
create_db()
|
create_db()
|
||||||
|
|||||||
@@ -78,20 +78,26 @@ async def render_file(
|
|||||||
stderr=asyncio.subprocess.PIPE,
|
stderr=asyncio.subprocess.PIPE,
|
||||||
)
|
)
|
||||||
|
|
||||||
_stdout, stderr = await proc.communicate()
|
stdout, stderr = await proc.communicate()
|
||||||
|
|
||||||
if proc.returncode:
|
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)
|
errors = await _build_errors(input_file=input_file, stderr=stderr)
|
||||||
return Result(error=errors)
|
return Result(error=errors)
|
||||||
|
|
||||||
return Result(result=output_file)
|
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]:
|
async def _build_errors(input_file: Path, stderr: bytes) -> list[RenderError]:
|
||||||
stderr_lines = stderr.decode("utf-8").splitlines()
|
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:
|
async with aiofiles.open(input_file, "r") as f:
|
||||||
lines = await f.readlines()
|
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
|
# No score exists, so we need to create it
|
||||||
set_source = lilypond_source.set_source(tune_set=lilypond_set)
|
set_source = lilypond_source.set_source(tune_set=lilypond_set)
|
||||||
out_filepath = files_service.get_set_filename(set_score_hash)
|
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:
|
async with files_service.tmp_file(content=set_source) as source_filepath:
|
||||||
if not pdf_filepath.exists():
|
if not pdf_filepath.exists():
|
||||||
pdf_result = await lilypond_render.render_file(
|
pdf_result = await lilypond_render.render_file(
|
||||||
|
|||||||
Reference in New Issue
Block a user