wallpaper
Some checks are pending
quality / changes (push) Waiting to run
quality / Flake Check (push) Blocked by required conditions
quality / Nix Format Check (push) Blocked by required conditions
quality / Deploy netty (push) Blocked by required conditions

This commit is contained in:
Harivansh Rathi 2026-04-10 21:11:41 -04:00
parent 29cffdc0fb
commit 010831e0c9
2 changed files with 19 additions and 8 deletions

View file

@ -19,14 +19,16 @@ let
close = 12; close = 12;
balanced = 11; balanced = 11;
wide = 10; wide = 10;
ultrawide = 9;
}; };
densityPresets = { densityPresets = {
sparse = 14; sparse = 14;
balanced = 20; balanced = 20;
dense = 28; dense = 28;
packed = 40;
}; };
view = "balanced"; view = "wide";
density = "balanced"; density = "dense";
candidatePool = { candidatePool = {
maxCached = 24; maxCached = 24;
randomAttempts = 20; randomAttempts = 20;
@ -55,7 +57,7 @@ let
}; };
label = label; label = label;
view = { view = {
tileConcurrency = 6; tileConcurrency = 3;
zoom = viewPresets.${view}; zoom = viewPresets.${view};
}; };
}; };

View file

@ -8,6 +8,7 @@ import os
import random import random
import subprocess import subprocess
import sys import sys
import time
import urllib.request import urllib.request
from datetime import datetime from datetime import datetime
from io import BytesIO from io import BytesIO
@ -254,11 +255,19 @@ def lat_lon_to_tile(lat: float, lon: float, zoom: int) -> tuple[int, int]:
def fetch_tile(z: int, x: int, y: int) -> Image.Image: def fetch_tile(z: int, x: int, y: int) -> Image.Image:
url = TILE_URL.format(z=z, x=x, y=y) url = TILE_URL.format(z=z, x=x, y=y)
req = urllib.request.Request(url, headers={"User-Agent": "wallpaper-gen/1.0"}) for attempt in range(4):
with urllib.request.urlopen(req, timeout=15) as resp: try:
tile = Image.open(BytesIO(resp.read())) req = urllib.request.Request(url, headers={"User-Agent": "wallpaper-gen/1.0"})
tile.load() with urllib.request.urlopen(req, timeout=15) as resp:
return tile tile = Image.open(BytesIO(resp.read()))
tile.load()
return tile
except (ConnectionResetError, urllib.error.URLError) as err:
if attempt == 3:
raise
delay = 0.5 * (2 ** attempt)
log(f"tile retry z={z} x={x} y={y} attempt={attempt + 1} delay={delay:.1f}s err={err!r}")
time.sleep(delay)
def fetch_tile_task(task: TileTask) -> tuple[int, int, Image.Image]: def fetch_tile_task(task: TileTask) -> tuple[int, int, Image.Image]: