Move the kiosk server to another machine; changes needed to make it work there.
[kiosk.git] / local_photos_mirror_renderer.py
index 390d6eabef0eab0d6230ad3075e10d012c4623a7..b27a7918feba389de82897941806bda83ee6ac99 100644 (file)
@@ -3,8 +3,9 @@
 import os
 import random
 import re
-from typing import List, Dict, Set
+from typing import Dict, Set
 
+import constants
 import file_writer
 import renderer
 
@@ -12,7 +13,7 @@ import renderer
 class local_photos_mirror_renderer(renderer.debuggable_abstaining_renderer):
     """A renderer that uses a local mirror of Google photos"""
 
-    album_root_directory = "/usr/local/export/www/gphotos/albums"
+    ALBUM_ROOT_DIR = "/var/www/kiosk/pages/images/gphotos/albums"
 
     album_whitelist = frozenset(
         [
@@ -86,7 +87,7 @@ class local_photos_mirror_renderer(renderer.debuggable_abstaining_renderer):
         """Walk the filesystem looking for photos in whitelisted albums and
         keep their paths in memory.
         """
-        for root, subdirs, files in os.walk(self.album_root_directory):
+        for root, subdirs, files in os.walk(self.ALBUM_ROOT_DIR):
             last_dir = root.rsplit("/", 1)[1]
             if self.album_is_in_whitelist(last_dir):
                 for filename in files:
@@ -94,7 +95,7 @@ class local_photos_mirror_renderer(renderer.debuggable_abstaining_renderer):
                     if extension in self.extension_whitelist:
                         photo_path = os.path.join(root, filename)
                         photo_url = photo_path.replace(
-                            "/usr/local/export/www/", "http://10.0.0.18/", 1
+                            "/var/www/", f"http://{constants.hostname}/", 1
                         )
                         self.candidate_photos.add(photo_url)
         return True