Skip to content

Commit 46b67fc

Browse files
committed
de-flake8'ed the rest of the source files in CBAPI
sensor_events.py in response is machine-generated, can't be linted properly - exclude it in setup.cfg
1 parent 8272d43 commit 46b67fc

File tree

7 files changed

+116
-107
lines changed

7 files changed

+116
-107
lines changed

setup.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ description-file = README.md
55
universal = 1
66

77
[flake8]
8+
exclude =
9+
src/cbapi/response/sensor_events.py,
10+
.svn,CVS,.bzr,.hg,.git,__pycache__,.tox
811
per-file-ignores = src/*/__init__.py:F401,F403
912
max-doc-length = 120
1013
max-line-length = 120

src/cbapi/response/cblr.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class LiveResponseSessionManager(CbLRManagerBase):
1414
cblr_session_cls = LiveResponseSession
1515

1616
def _get_or_create_session(self, sensor_id):
17-
sensor_sessions = [s for s in self._cb.get_object("{cblr_base}/session?active_only=true".format(cblr_base=self.cblr_base))
17+
sensor_sessions = [s for s in self._cb.get_object("{cblr_base}/session?active_only=true"
18+
.format(cblr_base=self.cblr_base))
1819
if s["sensor_id"] == sensor_id and s["status"] in ("pending", "active")]
1920

2021
if len(sensor_sessions) > 0:
@@ -41,7 +42,7 @@ def _close_session(self, session_id):
4142
session_data = self._cb.get_object("{cblr_base}/session/{0}".format(session_id, cblr_base=self.cblr_base))
4243
session_data["status"] = "close"
4344
self._cb.put_object("{cblr_base}/session/{0}".format(session_id, cblr_base=self.cblr_base), session_data)
44-
except:
45+
except Exception:
4546
pass
4647

4748
def _create_session(self, sensor_id):

src/cbapi/response/event.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ def __init__(self, cb, filename):
3333

3434
def run(self):
3535
while not self._fp.closed:
36-
l = self._fp.readline()
37-
if l == "":
36+
line = self._fp.readline()
37+
if line == "":
3838
# wait for new events
3939
sleep(1)
4040
continue
4141

4242
try:
43-
msg = json.loads(l)
43+
msg = json.loads(line)
4444
routing_key = msg.get("type")
4545
# log.debug("Received message with routing key %s" % routing_key)
46-
registry.eval_callback(routing_key, l, self._cb)
47-
except:
46+
registry.eval_callback(routing_key, line, self._cb)
47+
except Exception:
4848
pass
4949

5050
def stop(self):
@@ -76,8 +76,8 @@ def __init__(self, cb, listening_address, **kwargs):
7676
certfile = kwargs.get("certfile", None)
7777
if not keyfile or not certfile:
7878
raise CredentialError("Need to specify 'keyfile' and 'certfile' for HTTPS")
79-
self.httpd.socket = ssl.wrap_socket (self.httpd.socket, certfile=certfile, keyfile=keyfile,
80-
server_side=True)
79+
self.httpd.socket = ssl.wrap_socket(self.httpd.socket, certfile=certfile, keyfile=keyfile,
80+
server_side=True)
8181

8282
def run(self):
8383
self.httpd.serve_forever()
@@ -168,7 +168,7 @@ def on_connection_closed(self, connection, reply_code, reply_text):
168168
self._connection.ioloop.stop()
169169
else:
170170
log.warning('Connection closed, reopening in 5 seconds: (%s) %s',
171-
reply_code, reply_text)
171+
reply_code, reply_text)
172172
self._connection.add_timeout(5, self.reconnect)
173173

174174
def reconnect(self):
@@ -231,7 +231,7 @@ def on_channel_closed(self, channel, reply_code, reply_text):
231231
232232
"""
233233
log.warning('Channel %i was closed: (%s) %s',
234-
channel, reply_code, reply_text)
234+
channel, reply_code, reply_text)
235235
self._connection.close()
236236

237237
def setup_exchange(self, exchange_name):
@@ -282,7 +282,7 @@ def on_queue_declareok(self, method_frame):
282282
"""
283283
for routing_key in self.ROUTING_KEYS:
284284
log.debug('Binding %s to %s with %s',
285-
self.EXCHANGE, self.QUEUE, routing_key)
285+
self.EXCHANGE, self.QUEUE, routing_key)
286286
self._channel.queue_bind(self.on_bindok, self.QUEUE,
287287
self.EXCHANGE, routing_key)
288288

@@ -331,7 +331,7 @@ def on_consumer_cancelled(self, method_frame):
331331
332332
"""
333333
log.debug('Consumer was cancelled remotely, shutting down: %r',
334-
method_frame)
334+
method_frame)
335335
if self._channel:
336336
self._channel.close()
337337

@@ -419,7 +419,7 @@ def on_message(self, unused_channel, basic_deliver, properties, body):
419419
420420
"""
421421
log.debug('Received message # %s with properties %s',
422-
basic_deliver.delivery_tag, properties)
422+
basic_deliver.delivery_tag, properties)
423423

424424
registry.eval_callback(basic_deliver.routing_key, body, self._cb)
425425

0 commit comments

Comments
 (0)