Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
fixed lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianKuehnel committed Nov 13, 2017
1 parent a0b396a commit f1ce78e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions plantgw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from plantgw.misensor import Sensor


#pylint: disable-msg=too-many-instance-attributes
class Configuration(object):
"""Stores the program configuration."""

Expand Down Expand Up @@ -104,7 +105,7 @@ def get_name_string(sensor_list):
class PlantGateway(object):
"""Main class of the module."""

def __init__(self, config_file_path='~/.plantgw.yaml', start_client = True):
def __init__(self, config_file_path='~/.plantgw.yaml', start_client=True):
config_file_path = os.path.abspath(os.path.expanduser(config_file_path))
self.config = Configuration(config_file_path)
logging.info('loaded config file from %s', config_file_path)
Expand All @@ -114,10 +115,12 @@ def __init__(self, config_file_path='~/.plantgw.yaml', start_client = True):
self._start_client()

def start_client(self):
"""Start the mqtt client."""
if not self.connected:
self._start_client()

def stop_client(self):
"""Stop the mqtt client."""
if self.connected:
self.mqtt_client.disconnect()
self.connected = False
Expand Down Expand Up @@ -176,7 +179,7 @@ def process_all(self):
max_retry = 6 # number of retries
retry_count = 0

while retry_count < max_retry and len(next_list) > 0:
while retry_count < max_retry and next_list:
# if this is not the first try: wait some time before trying again
if retry_count > 0:
logging.info('try %d of %d: could not process sensor(s) %s. Waiting %d sec for next try',
Expand All @@ -190,10 +193,11 @@ def process_all(self):
for sensor in current_list:
try:
self.process_mac(sensor)
# pylint: disable=bare-except
except Exception as e:
# pylint: disable=bare-except, broad-except
except Exception as exception:
next_list.append(sensor) # if it failed, we'll try again in the next round
msg = "could not read data from {} ({}) with reason: {}".format(sensor.mac, sensor.alias, str(e))
msg = "could not read data from {} ({}) with reason: {}".format(
sensor.mac, sensor.alias, str(exception))
if sensor.fail_silent:
logging.error(msg)
logging.warning('fail_silent is set for sensor %s, so not raising an exception.', sensor.alias)
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ commands =
deps=
flake8
pylint
-r{toxinidir}/requirements.txt


[testenv:requirements]
Expand Down

0 comments on commit f1ce78e

Please sign in to comment.