Skip to content

Commit a37e806

Browse files
author
brentru
committed
black!
1 parent 373dd68 commit a37e806

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed

adafruit_fona/adafruit_fona.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class FONA:
7979
:param bool debug: Enable debugging output.
8080
8181
"""
82-
82+
8383
# Connection modes
8484
TCP_MODE = const(0)
8585
UDP_MODE = const(1)
@@ -290,7 +290,9 @@ def _set_gprs(self, gprs_on=True):
290290
return False
291291

292292
# disconnect all sockets
293-
if not self._send_check_reply(b"AT+CIPSHUT", reply=b"SHUT OK", timeout=20000):
293+
if not self._send_check_reply(
294+
b"AT+CIPSHUT", reply=b"SHUT OK", timeout=20000
295+
):
294296
return False
295297

296298
if not self._send_check_reply(b"AT+CGATT=1", reply=REPLY_OK, timeout=10000):
@@ -338,7 +340,9 @@ def _set_gprs(self, gprs_on=True):
338340
return False
339341

340342
# Open GPRS context
341-
if not self._send_check_reply(b"AT+SAPBR=1,1", reply=REPLY_OK, timeout=1850):
343+
if not self._send_check_reply(
344+
b"AT+SAPBR=1,1", reply=REPLY_OK, timeout=1850
345+
):
342346
return False
343347

344348
# Bring up wireless connection
@@ -514,7 +518,9 @@ def get_host_by_name(self, hostname):
514518

515519
if self._debug:
516520
print("\t---> AT+CDNSGIP=", hostname)
517-
if not self._send_check_reply(b'AT+CDNSGIP="' + hostname + b'"\r\n', reply=REPLY_OK):
521+
if not self._send_check_reply(
522+
b'AT+CDNSGIP="' + hostname + b'"\r\n', reply=REPLY_OK
523+
):
518524
return False
519525

520526
# attempt to parse a response
@@ -536,14 +542,14 @@ def get_socket(self):
536542
print("*** Allocating Socket")
537543

538544
self._uart.write(b"AT+CIPSTATUS\r\n")
539-
self._read_line(100) # OK
540-
self._read_line(100) # table header
545+
self._read_line(100) # OK
546+
self._read_line(100) # table header
541547

542548
for sock in range(0, FONA_MAX_SOCKETS):
543549
# parse and check for INITIAL client state
544550
self._read_line(100)
545-
self._parse_reply(b'C:', idx=5)
546-
if self._buf.strip('\"') == "INITIAL" or self._buf.strip('\"') == "CLOSED":
551+
self._parse_reply(b"C:", idx=5)
552+
if self._buf.strip('"') == "INITIAL" or self._buf.strip('"') == "CLOSED":
547553
break
548554
# read out the rest of the responses
549555
for _ in range(sock, FONA_MAX_SOCKETS):
@@ -688,7 +694,7 @@ def socket_close(self, sock_num, quick_close=1):
688694
sockets for the FONA module."
689695
self._read_line()
690696

691-
self._uart.write(b"AT+CIPCLOSE="+ str(sock_num).encode() + b",")
697+
self._uart.write(b"AT+CIPCLOSE=" + str(sock_num).encode() + b",")
692698
self._uart.write(str(sock_num).encode() + b"\r\n")
693699
self._read_line()
694700
if not self._parse_reply(b"CLOSE OK", idx=0):

adafruit_fona/adafruit_fona_socket.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
_the_interface = None # pylint: disable=invalid-name
3737

38+
3839
def set_interface(iface):
3940
"""Helper to set the global internet interface."""
4041
global _the_interface # pylint: disable=global-statement, invalid-name
@@ -83,7 +84,8 @@ def gethostbyname(hostname):
8384
:param str hostname: Desired hostname.
8485
"""
8586
addr = _the_interface.get_host_by_name(hostname)
86-
return addr.strip('\"')
87+
return addr.strip('"')
88+
8789

8890
# pylint: disable=invalid-name, redefined-builtin
8991
class socket:
@@ -107,24 +109,20 @@ def __init__(
107109
SOCKETS.append(self._socknum)
108110
self.settimeout(self._timeout)
109111

110-
111112
@property
112113
def socknum(self):
113114
"""Returns the socket object's socket number."""
114115
return self._socknum
115116

116-
117117
@property
118118
def connected(self):
119119
"""Returns whether or not we are connected to the socket."""
120120
return _the_interface.socket_status(self.socknum)
121121

122-
123122
def getpeername(self):
124123
"""Return the remote address to which the socket is connected."""
125124
return _the_interface.remote_ip(self.socknum)
126125

127-
128126
def inet_aton(self, ip_string):
129127
"""Convert an IPv4 address from dotted-quad string format.
130128
:param str ip_string: IP Address, as a dotted-quad string.
@@ -135,7 +133,6 @@ def inet_aton(self, ip_string):
135133
self._buffer = bytearray(self._buffer)
136134
return self._buffer
137135

138-
139136
def connect(self, address, conn_mode=None):
140137
"""Connect to a remote socket at address. (The format of address depends
141138
on the address family — see above.)

examples/fona_aio_post.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@
5757
counter = counter + 1
5858
print("OK")
5959
response = None
60-
time.sleep(15)
60+
time.sleep(15)

examples/fona_cheerlights.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@
7575
pixels.fill(gamma_corrected)
7676
last_value = value
7777
response = None
78-
time.sleep(60)
78+
time.sleep(60)

examples/fona_simpletest.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040
requests.set_socket(cellular_socket, fona)
4141

4242
print("My IP address is:", fona.local_ip)
43-
print(
44-
"IP lookup adafruit.com: %s" % fona.get_host_by_name("adafruit.com")
45-
)
43+
print("IP lookup adafruit.com: %s" % fona.get_host_by_name("adafruit.com"))
4644

4745
# fona._debug = True
4846
print("Fetching text from", TEXT_URL)

0 commit comments

Comments
 (0)