Compare commits
No commits in common. "2931a4ce1b7ae3390e6bb2086d3266fac473d925" and "a1a5db11b75aa984bc8038432f51f04038b26c79" have entirely different histories.
2931a4ce1b
...
a1a5db11b7
3 changed files with 15 additions and 26 deletions
|
@ -2,7 +2,7 @@
|
||||||
# build ui #
|
# build ui #
|
||||||
############
|
############
|
||||||
|
|
||||||
ARG NODE_VERSION=18.18
|
ARG NODE_VERSION=18.16
|
||||||
ARG PYTHON_VERSION=3.11-slim
|
ARG PYTHON_VERSION=3.11-slim
|
||||||
FROM node:${NODE_VERSION} AS build-ui
|
FROM node:${NODE_VERSION} AS build-ui
|
||||||
|
|
||||||
|
|
|
@ -100,33 +100,21 @@ async def get_all_auto_image_names(
|
||||||
return dict(zip(days, rnd.shuffled(ls)))
|
return dict(zip(days, rnd.shuffled(ls)))
|
||||||
|
|
||||||
|
|
||||||
async def get_all_manual_image_names(
|
|
||||||
manual_image_names: list[str] = Depends(list_images_manual),
|
|
||||||
) -> dict[int, str]:
|
|
||||||
"""
|
|
||||||
Bilder: "manual" zuordnen
|
|
||||||
"""
|
|
||||||
|
|
||||||
num_re = re.compile(r"/(\d+)\.", flags=re.IGNORECASE)
|
|
||||||
return {
|
|
||||||
int(num_match.group(1)): name
|
|
||||||
for name in manual_image_names
|
|
||||||
if (num_match := num_re.search(name)) is not None
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
async def get_all_image_names(
|
async def get_all_image_names(
|
||||||
auto_image_names: dict[int, str] = Depends(get_all_auto_image_names),
|
auto_image_names: dict[int, str] = Depends(get_all_auto_image_names),
|
||||||
manual_image_names: dict[int, str] = Depends(get_all_manual_image_names),
|
manual_image_names: list[str] = Depends(list_images_manual),
|
||||||
) -> dict[int, str]:
|
) -> dict[int, str]:
|
||||||
"""
|
"""
|
||||||
Bilder "auto" und "manual" zu Tagen zuordnen
|
Bilder "auto" und "manual" zu Tagen zuordnen
|
||||||
"""
|
"""
|
||||||
|
|
||||||
result = auto_image_names.copy()
|
num_re = re.compile(r"/(\d+)\.", flags=re.IGNORECASE)
|
||||||
result.update(manual_image_names)
|
|
||||||
|
|
||||||
return result
|
for name in manual_image_names:
|
||||||
|
assert (num_match := num_re.search(name)) is not None
|
||||||
|
auto_image_names[int(num_match.group(1))] = name
|
||||||
|
|
||||||
|
return auto_image_names
|
||||||
|
|
||||||
|
|
||||||
@dataclass(slots=True, frozen=True)
|
@dataclass(slots=True, frozen=True)
|
||||||
|
@ -196,7 +184,6 @@ async def get_day_image(
|
||||||
day: int,
|
day: int,
|
||||||
days: list[int] = Depends(get_all_sorted_days),
|
days: list[int] = Depends(get_all_sorted_days),
|
||||||
cfg: Config = Depends(get_config),
|
cfg: Config = Depends(get_config),
|
||||||
manual_image_names: dict[int, str] = Depends(get_all_manual_image_names),
|
|
||||||
auto_image_names: dict[int, str] = Depends(get_all_auto_image_names),
|
auto_image_names: dict[int, str] = Depends(get_all_auto_image_names),
|
||||||
day_parts: dict[int, str] = Depends(get_all_parts),
|
day_parts: dict[int, str] = Depends(get_all_parts),
|
||||||
ttfonts: list[TTFont] = Depends(get_all_ttfonts),
|
ttfonts: list[TTFont] = Depends(get_all_ttfonts),
|
||||||
|
@ -209,14 +196,14 @@ async def get_day_image(
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Versuche "manual"-Bild zu laden
|
# Versuche, aus "manual"-Ordner zu laden
|
||||||
img = await load_image(manual_image_names[day])
|
img = await load_image(f"images_manual/{day}.jpg")
|
||||||
|
|
||||||
# Als AdventImage verarbeiten
|
# Als AdventImage verarbeiten
|
||||||
image = await AdventImage.from_img(img, cfg)
|
image = await AdventImage.from_img(img, cfg)
|
||||||
return image.img
|
return image.img
|
||||||
|
|
||||||
except (KeyError, RuntimeError):
|
except RuntimeError:
|
||||||
# Erstelle automatisch generiertes Bild
|
# Erstelle automatisch generiertes Bild
|
||||||
return await gen_day_auto_image(
|
return await gen_day_auto_image(
|
||||||
day=day,
|
day=day,
|
||||||
|
|
|
@ -2,10 +2,12 @@ import { AxiosError } from "axios";
|
||||||
import { toast } from "bulma-toast";
|
import { toast } from "bulma-toast";
|
||||||
|
|
||||||
export class APIError extends Error {
|
export class APIError extends Error {
|
||||||
axios_error?: AxiosError;
|
reason: unknown;
|
||||||
|
axios_error: AxiosError | null = null;
|
||||||
|
|
||||||
constructor(reason: unknown, endpoint: string) {
|
constructor(reason: unknown, endpoint: string) {
|
||||||
super(endpoint); // sets this.message to the endpoint
|
super(endpoint); // sets this.message to the endpoint
|
||||||
|
this.reason = reason;
|
||||||
Object.setPrototypeOf(this, APIError.prototype);
|
Object.setPrototypeOf(this, APIError.prototype);
|
||||||
|
|
||||||
if (reason instanceof AxiosError) {
|
if (reason instanceof AxiosError) {
|
||||||
|
@ -19,7 +21,7 @@ export class APIError extends Error {
|
||||||
let code = "U";
|
let code = "U";
|
||||||
const result = () => `${msg} (Fehlercode: ${code}/${this.message})`;
|
const result = () => `${msg} (Fehlercode: ${code}/${this.message})`;
|
||||||
|
|
||||||
if (this.axios_error === undefined) return result();
|
if (this.axios_error === null) return result();
|
||||||
|
|
||||||
switch (this.axios_error.code) {
|
switch (this.axios_error.code) {
|
||||||
case "ECONNABORTED":
|
case "ECONNABORTED":
|
||||||
|
|
Loading…
Reference in a new issue