From daa6273b65452c3d39f3e625876ef14a544d1add Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Thu, 6 May 2021 13:37:58 -0700 Subject: [PATCH] Change to using try/except blocks --- src/board.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) 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 -- 2.49.0