Skip to content

Commit dc5ffd6

Browse files
author
Kevin Townsend
committed
Resolved pylint whitespace warnings
1 parent 5afcc66 commit dc5ffd6

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

adafruit_bluefruitspi.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
from ustruct import pack_into, unpack
5858

5959

60-
class MsgType: #pylint: disable=too-few-public-methods
60+
class MsgType: #pylint: disable=too-few-public-methods,bad-whitespace
6161
"""An enum-like class representing the possible message types.
6262
Possible values are:
6363
- ``MsgType.COMMAND``
@@ -71,7 +71,7 @@ class MsgType: #pylint: disable=too-few-public-methods
7171
ERROR = const(0x80) # Error message
7272

7373

74-
class SDEPCommand: #pylint: disable=too-few-public-methods
74+
class SDEPCommand: #pylint: disable=too-few-public-methods,bad-whitespace
7575
"""An enum-like class representing the possible SDEP commands.
7676
Possible values are:
7777
- ``SDEPCommand.INITIALIZE``
@@ -85,7 +85,7 @@ class SDEPCommand: #pylint: disable=too-few-public-methods
8585
BLEUART_RX = const(0x0A02) # BLE UART read data
8686

8787

88-
class ArgType: #pylint: disable=too-few-public-methods
88+
class ArgType: #pylint: disable=too-few-public-methods,bad-whitespace
8989
"""An enum-like class representing the possible argument types.
9090
Possible values are
9191
- ``ArgType.STRING``
@@ -107,7 +107,7 @@ class ArgType: #pylint: disable=too-few-public-methods
107107
UINT8 = const(0x0800) # Unsigned 8-bit integer data type
108108

109109

110-
class ErrorCode: #pylint: disable=too-few-public-methods
110+
class ErrorCode: #pylint: disable=too-few-public-methods,bad-whitespace
111111
"""An enum-like class representing possible error codes.
112112
Possible values are
113113
- ``ErrorCode.``
@@ -151,6 +151,9 @@ def __init__(self, spi, cs, irq, debug=False):
151151
self._spi.unlock()
152152

153153
def cmd(self, cmd):
154+
"""Executes the supplied AT command, which must be terminated with
155+
a new-line (\n) character.
156+
"""
154157
# Make sure we stay within the 20 byte limit
155158
if len(cmd) > 16:
156159
# TODO: Split command into multiple packets
@@ -180,7 +183,7 @@ def cmd(self, cmd):
180183
if timeout <= 0:
181184
if self._debug:
182185
print("ERROR: Timed out waiting for a response.")
183-
raise Exception('Timed out waiting for a response.')
186+
raise RuntimeError('Timed out waiting for a response.')
184187

185188
# Retrieve the response message
186189
msgtype = 0

examples/bluefruitspi_simpletest.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import busio
22
import digitalio
33
import board
4-
try:
5-
from struct import pack_into, unpack
6-
except ImportError:
7-
from ustruct import pack_into, unpack
84

95
from adafruit_bluefruitspi import BluefruitSPI, MsgType
106

@@ -16,13 +12,11 @@
1612
# Send the ATI command
1713
try:
1814
msgtype, msgid, rsp = bluefruit.cmd("ATI\n")
19-
except Exception as error:
15+
if msgtype == MsgType.ERROR:
16+
print("Error (id:{0})".format(hex(msgid)))
17+
if msgtype == MsgType.RESPONSE:
18+
print("Response:")
19+
print(rsp)
20+
except RuntimeError as error:
2021
print("AT command failure: " + repr(error))
2122
exit()
22-
23-
# Parse response packet
24-
if msgtype == MsgType.ERROR:
25-
print("Error (id:{0})".format(hex(msgid)))
26-
if msgtype == MsgType.RESPONSE:
27-
print("Response:")
28-
print(rsp)

0 commit comments

Comments
 (0)