Skip to content

Commit 9f98c48

Browse files
ImageView app: improve error handling
1 parent 9abada9 commit 9f98c48

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

internal_filesystem/apps/com.micropythonos.imageview/META-INF/MANIFEST.JSON

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"publisher": "MicroPythonOS",
44
"short_description": "Image Viewer",
55
"long_description": "Opens and shows images on the display.",
6-
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.imageview/icons/com.micropythonos.imageview_0.0.3_64x64.png",
7-
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.imageview/mpks/com.micropythonos.imageview_0.0.3.mpk",
6+
"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.imageview/icons/com.micropythonos.imageview_0.0.4_64x64.png",
7+
"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.imageview/mpks/com.micropythonos.imageview_0.0.4.mpk",
88
"fullname": "com.micropythonos.imageview",
9-
"version": "0.0.3",
9+
"version": "0.0.4",
1010
"category": "graphics",
1111
"activities": [
1212
{

internal_filesystem/apps/com.micropythonos.imageview/assets/imageview.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,27 @@ def onCreate(self):
6161
def onResume(self, screen):
6262
self.stopping = False
6363
self.images.clear()
64-
for item in os.listdir(self.imagedir):
65-
print(item)
66-
lowercase = item.lower()
67-
if lowercase.endswith(".jpg") or lowercase.endswith(".jpeg") or lowercase.endswith(".png") or lowercase.endswith(".raw") or lowercase.endswith(".gif"):
64+
try:
65+
for item in os.listdir(self.imagedir):
66+
print(item)
67+
lowercase = item.lower()
68+
if not (lowercase.endswith(".jpg") or lowercase.endswith(".jpeg") or lowercase.endswith(".png") or lowercase.endswith(".raw") or lowercase.endswith(".gif")):
69+
continue
6870
fullname = f"{self.imagedir}/{item}"
6971
size = os.stat(fullname)[6]
7072
print(f"size: {size}")
7173
if size > 10 * 1024*1024:
7274
print(f"Skipping file of size {size}")
7375
continue
7476
self.images.append(fullname)
75-
self.images.sort()
76-
# Begin with one image:
77-
self.show_next_image()
78-
self.stop_fullscreen()
79-
#self.image_timer = lv.timer_create(self.show_next_image, 1000, None)
77+
78+
self.images.sort()
79+
# Begin with one image:
80+
self.show_next_image()
81+
self.stop_fullscreen()
82+
#self.image_timer = lv.timer_create(self.show_next_image, 1000, None)
83+
except Exception as e:
84+
print(f"ImageView encountered exception for {self.imagedir}: {e}")
8085

8186
def onStop(self, screen):
8287
print("ImageView stopping")

0 commit comments

Comments
 (0)