From 9f98c48bd13a6fdea8ae1d10604b9be573b8a962 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Fri, 21 Nov 2025 18:45:10 +0100 Subject: [PATCH] ImageView app: improve error handling --- .../META-INF/MANIFEST.JSON | 6 ++--- .../assets/imageview.py | 23 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/internal_filesystem/apps/com.micropythonos.imageview/META-INF/MANIFEST.JSON b/internal_filesystem/apps/com.micropythonos.imageview/META-INF/MANIFEST.JSON index 705ae849..a0a333f7 100644 --- a/internal_filesystem/apps/com.micropythonos.imageview/META-INF/MANIFEST.JSON +++ b/internal_filesystem/apps/com.micropythonos.imageview/META-INF/MANIFEST.JSON @@ -3,10 +3,10 @@ "publisher": "MicroPythonOS", "short_description": "Image Viewer", "long_description": "Opens and shows images on the display.", -"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.imageview/icons/com.micropythonos.imageview_0.0.3_64x64.png", -"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.imageview/mpks/com.micropythonos.imageview_0.0.3.mpk", +"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.imageview/icons/com.micropythonos.imageview_0.0.4_64x64.png", +"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.imageview/mpks/com.micropythonos.imageview_0.0.4.mpk", "fullname": "com.micropythonos.imageview", -"version": "0.0.3", +"version": "0.0.4", "category": "graphics", "activities": [ { diff --git a/internal_filesystem/apps/com.micropythonos.imageview/assets/imageview.py b/internal_filesystem/apps/com.micropythonos.imageview/assets/imageview.py index 55fac865..072160e0 100644 --- a/internal_filesystem/apps/com.micropythonos.imageview/assets/imageview.py +++ b/internal_filesystem/apps/com.micropythonos.imageview/assets/imageview.py @@ -61,10 +61,12 @@ class ImageView(Activity): def onResume(self, screen): self.stopping = False self.images.clear() - for item in os.listdir(self.imagedir): - print(item) - lowercase = item.lower() - if lowercase.endswith(".jpg") or lowercase.endswith(".jpeg") or lowercase.endswith(".png") or lowercase.endswith(".raw") or lowercase.endswith(".gif"): + try: + for item in os.listdir(self.imagedir): + print(item) + lowercase = item.lower() + if not (lowercase.endswith(".jpg") or lowercase.endswith(".jpeg") or lowercase.endswith(".png") or lowercase.endswith(".raw") or lowercase.endswith(".gif")): + continue fullname = f"{self.imagedir}/{item}" size = os.stat(fullname)[6] print(f"size: {size}") @@ -72,11 +74,14 @@ class ImageView(Activity): print(f"Skipping file of size {size}") continue self.images.append(fullname) - self.images.sort() - # Begin with one image: - self.show_next_image() - self.stop_fullscreen() - #self.image_timer = lv.timer_create(self.show_next_image, 1000, None) + + self.images.sort() + # Begin with one image: + self.show_next_image() + self.stop_fullscreen() + #self.image_timer = lv.timer_create(self.show_next_image, 1000, None) + except Exception as e: + print(f"ImageView encountered exception for {self.imagedir}: {e}") def onStop(self, screen): print("ImageView stopping")