Skip to content

Commit 0ac4cb0

Browse files
authored
Merge pull request #32 from adafruit/linting
Fixed cyclic import
2 parents ca173b8 + c391f5f commit 0ac4cb0

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

adafruit_wiznet5k/adafruit_wiznet5k_socket.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import gc
1616
import time
1717
from micropython import const
18-
from adafruit_wiznet5k import adafruit_wiznet5k
18+
import adafruit_wiznet5k as wiznet5k
1919

2020
_the_interface = None # pylint: disable=invalid-name
2121

@@ -115,12 +115,12 @@ def __exit__(self, exc_type, exc_val, exc_tb):
115115
if self._sock_type == SOCK_STREAM:
116116
self.disconnect()
117117
stamp = time.monotonic()
118-
while self.status == adafruit_wiznet5k.SNSR_SOCK_FIN_WAIT:
118+
while self.status == wiznet5k.adafruit_wiznet5k.SNSR_SOCK_FIN_WAIT:
119119
if time.monotonic() - stamp > 1000:
120120
raise RuntimeError("Failed to disconnect socket")
121121
self.close()
122122
stamp = time.monotonic()
123-
while self.status != adafruit_wiznet5k.SNSR_SOCK_CLOSED:
123+
while self.status != wiznet5k.adafruit_wiznet5k.SNSR_SOCK_CLOSED:
124124
if time.monotonic() - stamp > 1000:
125125
raise RuntimeError("Failed to close socket")
126126

@@ -140,16 +140,19 @@ def connected(self):
140140
if self.socknum >= _the_interface.max_sockets:
141141
return False
142142
status = _the_interface.socket_status(self.socknum)[0]
143-
if status == adafruit_wiznet5k.SNSR_SOCK_CLOSE_WAIT and self.available() == 0:
143+
if (
144+
status == wiznet5k.adafruit_wiznet5k.SNSR_SOCK_CLOSE_WAIT
145+
and self.available() == 0
146+
):
144147
result = False
145148
else:
146149
result = status not in (
147-
adafruit_wiznet5k.SNSR_SOCK_CLOSED,
148-
adafruit_wiznet5k.SNSR_SOCK_LISTEN,
149-
adafruit_wiznet5k.SNSR_SOCK_TIME_WAIT,
150-
adafruit_wiznet5k.SNSR_SOCK_FIN_WAIT,
150+
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_CLOSED,
151+
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_LISTEN,
152+
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_TIME_WAIT,
153+
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_FIN_WAIT,
151154
)
152-
if not result and status != adafruit_wiznet5k.SNSR_SOCK_LISTEN:
155+
if not result and status != wiznet5k.adafruit_wiznet5k.SNSR_SOCK_LISTEN:
153156
self.close()
154157
return result
155158

@@ -195,12 +198,12 @@ def accept(self):
195198
"""
196199
stamp = time.monotonic()
197200
while self.status not in (
198-
adafruit_wiznet5k.SNSR_SOCK_SYNRECV,
199-
adafruit_wiznet5k.SNSR_SOCK_ESTABLISHED,
201+
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_SYNRECV,
202+
wiznet5k.adafruit_wiznet5k.SNSR_SOCK_ESTABLISHED,
200203
):
201204
if self._timeout > 0 and time.monotonic() - stamp > self._timeout:
202205
return None
203-
if self.status == adafruit_wiznet5k.SNSR_SOCK_CLOSED:
206+
if self.status == wiznet5k.adafruit_wiznet5k.SNSR_SOCK_CLOSED:
204207
self.close()
205208
self.listen()
206209

@@ -212,7 +215,7 @@ def accept(self):
212215
self._socknum = new_listen_socknum # pylint: disable=protected-access
213216
self.bind((None, self._listen_port))
214217
self.listen()
215-
while self.status != adafruit_wiznet5k.SNSR_SOCK_LISTEN:
218+
while self.status != wiznet5k.adafruit_wiznet5k.SNSR_SOCK_LISTEN:
216219
raise RuntimeError("Failed to open new listening socket")
217220
return client_sock, addr
218221

0 commit comments

Comments
 (0)