From: Melissa LeBlanc-Williams Date: Thu, 6 May 2021 20:37:58 +0000 (-0700) Subject: Change to using try/except blocks X-Git-Tag: 6.7.0^2~2 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/daa6273b65452c3d39f3e625876ef14a544d1add Change to using try/except blocks --- diff --git a/src/board.py b/src/board.py index cb8c6c8..1b42b53 100755 --- a/src/board.py +++ b/src/board.py @@ -224,15 +224,19 @@ elif "sphinx" in sys.modules: else: raise NotImplementedError("Board not supported {}".format(board_id)) -if SDA and SCL: +try: + if SDA and SCL: - def I2C(): - """The singleton I2C interface""" - return busio.I2C(SCL, SDA) + def I2C(): + """The singleton I2C interface""" + return busio.I2C(SCL, SDA) + if SCLK: -if SCLK: + def SPI(): + """The singleton SPI interface""" + return busio.SPI(SCLK, MOSI, MISO) - def SPI(): - """The singleton SPI interface""" - return busio.SPI(SCLK, MOSI, MISO) + +except NameError: + pass