Skip to content

Commit 04f57c2

Browse files
authored
Tested Error handling for images
1 parent d26fa80 commit 04f57c2

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

PyPortal_ViewMaster/viewmaster.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
vfs = storage.VfsFat(sdcard)
2121
storage.mount(vfs, "/sd")
2222
IMAGE_DIRECTORY = "/sd/images"
23-
except OSerror:
23+
except OSError as error:
2424
print("No SD card, will only look on internal memory")
2525

2626
def print_directory(path, tabs=0):
@@ -48,9 +48,12 @@ def print_directory(path, tabs=0):
4848
if isdir:
4949
print_directory(path + "/" + file, tabs + 1)
5050

51-
print_directory(IMAGE_DIRECTORY)
51+
try:
52+
print_directory(IMAGE_DIRECTORY)
53+
except OSError as error:
54+
raise Exception("No images found on flash or SD Card")
5255

53-
# Create the slideshow object that plays through once alphabetically
56+
# Create the slideshow object that plays through once alphabetically.
5457
slideshow = SlideShow(board.DISPLAY, None, folder=IMAGE_DIRECTORY, loop=True,
5558
order=PlayBackOrder.ALPHABETICAL, dwell=0)
5659
while True:

0 commit comments

Comments
 (0)