From 212392b3c25fbdf253907cb0e50dc312545dd43d Mon Sep 17 00:00:00 2001 From: Keith Schincke Date: Sun, 12 May 2019 14:04:50 -0500 Subject: [PATCH] Add sd_check function to pyportal Both __init__ and fetch access the in self._sdcard parameter to determine if a SD card is installed. __init__ handles the mounting of the card. fetch() alters the filename path as needed prior to calling wget(). This new function will allow the calling of pyportal.sd_check() to determine if a card is present and alter operations as needed. Simple example: if pyportal.sdcheck(): print("SD card is installed") else: print("SD card is NOT installed") --- adafruit_pyportal.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 521a1cd..ca218f2 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -661,6 +661,13 @@ def image_converter_url(image_url, width, height, color_depth=16): return IMAGE_CONVERTER_SERVICE % (aio_username, aio_key, width, height, color_depth, image_url) + def sd_check(self): + """Returns True if there is an SD card preset and False + if there is no SD card. The _sdcard value is set in _init + """ + if self._sdcard: + return True + return False def fetch(self, refresh_url=None): """Fetch data from the url we initialized with, perfom any parsing,