Retries and simplification
This commit is contained in:
parent
39a7d9546e
commit
cd70c4cdca
1 changed files with 391 additions and 345 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import fcntl
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime
|
||||
|
|
@ -12,6 +13,8 @@ from waveshare_epd import epd7in3e
|
|||
from immich import ImmichClient, get_random_photo_of_people, get_random_photo_from_album
|
||||
from homeassistant import HomeAssistantClient
|
||||
|
||||
LOCK_FILE = "/tmp/frame.lock"
|
||||
|
||||
IMMICH_URL = os.environ.get("IMMICH_URL", "https://immich.schmelczer.dev")
|
||||
IMMICH_API_KEY = os.environ.get("IMMICH_API_KEY", "6crxVS1JLTJxsfGlzVhN2kefdL4EP7HPkkoMk9L6ZOE")
|
||||
|
||||
|
|
@ -51,6 +54,13 @@ def main() -> None:
|
|||
parser.add_argument("--no-enhance", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
lock_fd = open(LOCK_FILE, "w")
|
||||
try:
|
||||
fcntl.flock(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
except BlockingIOError:
|
||||
print("Another instance running, skipping")
|
||||
sys.exit(0)
|
||||
|
||||
now = datetime.now()
|
||||
print(f"Time: {now.strftime('%H:%M')}")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue