Skip to content

Commit 9d84573

Browse files
committed
pylint issues fixed
1 parent c7edeed commit 9d84573

File tree

12 files changed

+860
-805
lines changed

12 files changed

+860
-805
lines changed

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ smbus2 = "^0.4.2"
3636
psutil = "^5.9.1"
3737
plantower = "^0.0.11"
3838
setuptools = "^63.2.0"
39-
ez_setup = "^0.9"
4039
libssl-dev = "^1.1.0"
4140
pycurl = "^7.45.1"
4241
distro = "^1.7.0"

requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ smbus2
88
psutil
99
plantower
1010
setuptools
11-
ez_setup
1211
pycurl
1312
distro

sensors2mqtt/Sensor.py

+65-54
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
#!/usr/bin/python3
2-
2+
33
# This file is part of the sensors2mqtt distribution (https://github.com/DCL777/sensors2mqtt.git).
4-
# Copyright (c) 2020 Dries Claerbout
5-
#
6-
# This program is free software: you can redistribute it and/or modify
7-
# it under the terms of the GNU General Public License as published by
4+
# Copyright (c) 2020 Dries Claerbout
5+
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
88
# the Free Software Foundation, version 3.
9-
#
10-
# This program is distributed in the hope that it will be useful, but
11-
# WITHOUT ANY WARRANTY; without even the implied warranty of
12-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9+
10+
# This program is distributed in the hope that it will be useful, but
11+
# WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1313
# General Public License for more details.
14-
#
15-
# You should have received a copy of the GNU General Public License
14+
15+
# You should have received a copy of the GNU General Public License
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
import logging
1919

2020
import os.path
21-
from os import path
21+
# from os import path
22+
2223

2324
class BColors:
25+
"""CLI colors"""
2426
HEADER = '\033[95m'
2527
OKBLUE = '\033[94m'
2628
OKCYAN = '\033[96m'
@@ -31,46 +33,55 @@ class BColors:
3133
BOLD = '\033[1m'
3234
UNDERLINE = '\033[4m'
3335

36+
3437
class Sensor:
35-
def __init__(self, supported_system, manufacturer, sensorName, function,protocol,mqtt_client, parameters):
36-
self.supported_system = supported_system
37-
self.manufacturer = manufacturer
38-
self.sensorName = sensorName
39-
self.function = function
40-
self.protocol = protocol
41-
self.mqtt_client = mqtt_client
42-
43-
self.update_interval = parameters['update_interval']
44-
45-
# replace spaces and dashes to underscore !!
46-
sensorNameModified = self.sensorName.replace(' ', '_')
47-
sensorNameModified = sensorNameModified.replace('-','_')
48-
49-
self.ownDir = f"{os.getcwd()}/sensors/{self.manufacturer}_{sensorNameModified}/"
50-
51-
self.parameters = parameters #.get(f"{self.supported_system}_{self.manufacturer}_{sensorNameModified}")
52-
self.logger = logging.getLogger(__name__)
53-
54-
55-
def printInfo(self):
56-
print(f"{BColors.OKCYAN} -> {self.sensorName} \t {self.manufacturer} \t {self.function} \t {self.protocol} \t {self.supported_system}{BColors.ENDC}")
57-
#self.count = 0
58-
#for a_sensor in self.parameters:
59-
# self.count = self.count +1
60-
#print(f" -> Sensor {self.count}:")
61-
for an_item in self.parameters.items():
62-
print(f" -> {an_item[0]} = {an_item[1]}")
63-
#print(f" -> {an_item}")
64-
#print(f" -> {a_sensor.items()}")
65-
66-
def is_configured(self):
67-
return bool(self.parameters)
68-
69-
def send_value_over_mqtt(self,mqtt_top_dir_name):
70-
pass
71-
72-
def on_exit(self):
73-
pass
74-
75-
def get_update_interval(self):
76-
return self.update_interval
38+
"""Default sensor class. Every sensor must be a instance of this class"""
39+
40+
def __init__(self, supported_system, manufacturer, sensor_name,
41+
function, protocol, mqtt_client, parameters):
42+
self.supported_system = supported_system
43+
self.manufacturer = manufacturer
44+
self.sensor_name = sensor_name
45+
self.function = function
46+
self.protocol = protocol
47+
self.mqtt_client = mqtt_client
48+
49+
self.update_interval = parameters['update_interval']
50+
51+
# replace spaces and dashes to underscore !!
52+
sensor_name_modified = self.sensor_name.replace(' ', '_')
53+
sensor_name_modified = sensor_name_modified.replace('-', '_')
54+
55+
self.own_dir = f"{os.getcwd()}/sensors/{self.manufacturer}_{sensor_name_modified}/"
56+
57+
# .get(f"{self.supported_system}_{self.manufacturer}_{sensorNameModified}")
58+
self.parameters = parameters
59+
self.logger = logging.getLogger(__name__)
60+
61+
def print_info(self):
62+
""" Print info about the used parameters """
63+
print(f"{BColors.OKCYAN} -> {self.sensor_name} \t {self.manufacturer} \t {self.function} \t {self.protocol} \t {self.supported_system}{BColors.ENDC}")
64+
#self.count = 0
65+
# for a_sensor in self.parameters:
66+
# self.count = self.count +1
67+
#print(f" -> Sensor {self.count}:")
68+
for an_item in self.parameters.items():
69+
print(f" -> {an_item[0]} = {an_item[1]}")
70+
#print(f" -> {an_item}")
71+
#print(f" -> {a_sensor.items()}")
72+
73+
def is_configured(self):
74+
""" is configured? """
75+
return bool(self.parameters)
76+
77+
def send_value_over_mqtt(self, mqtt_top_dir_name):
78+
""" send the actual sensor value over MQTT"""
79+
# pass
80+
81+
def on_exit(self):
82+
""" Do this on exit """
83+
# pass
84+
85+
def get_update_interval(self):
86+
""" Get the wanted update interval for this sensor """
87+
return self.update_interval

0 commit comments

Comments
 (0)