Module: check_mk
Branch: master
Commit: 72a9877bf3cbdfd714364eebfbddf31bc0bd21f5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=72a9877bf3cbdf…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Jul 27 11:35:50 2018 +0200
Fixed and enabled cell-var-from-loop warning.
Change-Id: Id1ae57594f46f4ee7d985a48b23133f8a724af4e
---
checks/cmciii | 7 +++----
checks/emka_modules | 3 ++-
checks/lgp_pdu_aux | 2 +-
cmk/ec/main.py | 4 +++-
cmk/gui/multitar.py | 4 +++-
cmk/gui/watolib.py | 8 ++++++--
cmk_base/snmp_scan.py | 9 +++------
tests/pylint/pylintrc | 1 -
8 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/checks/cmciii b/checks/cmciii
index db6adea..e9ea718 100644
--- a/checks/cmciii
+++ b/checks/cmciii
@@ -158,12 +158,11 @@ def parse_cmciii(info):
# pos. scale: "X" => "* X"
# else: => "* 1"
if int(scale) < 0:
- scale_f = lambda a: -1.0 * float(a) / float(scale)
+ value = float(value_int) * (-1.0 / float(scale))
elif int(scale) > 0:
- scale_f = lambda a: float(a) * float(scale)
+ value = float(value_int) * float(scale)
else:
- scale_f = int
- value = scale_f(value_int)
+ value = int(value_int)
if "Power" in container or "Energy" in container:
value = value * 1000 # kW, kWh
diff --git a/checks/emka_modules b/checks/emka_modules
index a43ae22..ae43720 100644
--- a/checks/emka_modules
+++ b/checks/emka_modules
@@ -133,8 +133,9 @@ def parse_emka_modules(info):
m, a = map(float, equation)
else:
m, a = 1.0, 0.0
+ def scale_f(x, m=m, a=a):
+ return float(x)*m+a
- scale_f = lambda x: float(x)*m+a
location = str(chr(oidend[0]))
for sensor, attrs in parsed.get("sensor", {}).items():
if attrs["_location_"].endswith(".%s" % location):
diff --git a/checks/lgp_pdu_aux b/checks/lgp_pdu_aux
index 912669f..dac2b77 100644
--- a/checks/lgp_pdu_aux
+++ b/checks/lgp_pdu_aux
@@ -132,7 +132,7 @@ def check_lgp_pdu_aux(item, params, info):
else:
output.append('Label: ' + pdu['SystemLabel'])
- def handle_type(ty, label, uom):
+ def handle_type(ty, label, uom, pdu=pdu):
state = 0
perfdata = (ty.lower(), pdu[ty],
'%0.2f:%0.2f' % (pdu[ty+'LowWarn'],
pdu[ty+'HighWarn']),
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index a79f877..10d39a3 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -1055,7 +1055,9 @@ class EventServer(ECServerThread):
line = scrub_and_decode(line.rstrip())
if line:
try:
- self.process_raw_data(lambda: self.process_line(line, address))
+ def handler(line=line):
+ self.process_line(line, address)
+ self.process_raw_data(handler)
except Exception as e:
self._logger.exception('Exception handling a log line (skipping
this one): %s' % e)
diff --git a/cmk/gui/multitar.py b/cmk/gui/multitar.py
index 05c760c..f7b2ced 100644
--- a/cmk/gui/multitar.py
+++ b/cmk/gui/multitar.py
@@ -381,8 +381,10 @@ def create(tar_filename, components):
subtar_buffer = cStringIO.StringIO()
with tarfile.TarFile(fileobj=subtar_buffer, mode="w") as
subtar_obj:
+ def exclude_filter(x, excludes=excludes):
+ return filter_subtar_files(x, excludes)
subtar_obj.add(os.path.join(basedir, filename), arcname=filename,
- filter=lambda x: filter_subtar_files(x, excludes))
+ filter=exclude_filter)
subtar_size = len(subtar_buffer.getvalue())
subtar_buffer.seek(0)
diff --git a/cmk/gui/watolib.py b/cmk/gui/watolib.py
index 4a20203..d49152c 100644
--- a/cmk/gui/watolib.py
+++ b/cmk/gui/watolib.py
@@ -6235,7 +6235,9 @@ def get_snapshot_status(snapshot, validate_checksums = False):
else: # new snapshots
for entry in ["comment", "created_by",
"type"]:
if entry in status["files"]:
- status[entry] = access_snapshot(lambda x:
multitar.get_file_content(x, entry))
+ def handler(x, entry=entry):
+ return multitar.get_file_content(x, entry)
+ status[entry] = access_snapshot(handler)
else:
raise MKGeneralException(_("Invalid snapshot (missing file:
%s)") % entry)
@@ -6296,7 +6298,9 @@ def get_snapshot_status(snapshot, validate_checksums = False):
checksum, signed = checksums[filename]
# Get hashes of file in question
- subtar = access_snapshot(lambda x: multitar.get_file_content(x, filename))
+ def handler(x, filename=filename):
+ return multitar.get_file_content(x, filename)
+ subtar = access_snapshot(handler)
subtar_hash = sha256(subtar).hexdigest()
subtar_signed = sha256(subtar_hash + snapshot_secret()).hexdigest()
diff --git a/cmk_base/snmp_scan.py b/cmk_base/snmp_scan.py
index 1ccfe8c..548b008 100644
--- a/cmk_base/snmp_scan.py
+++ b/cmk_base/snmp_scan.py
@@ -115,12 +115,9 @@ def _snmp_scan(access_data, on_error="ignore",
for_inv=False, do_snmp_scan=True,
if scan_function:
try:
- def oid_function(oid, default_value=None):
- value = snmp.get_single_oid(access_data, oid, check_plugin_name,
do_snmp_scan=do_snmp_scan)
- if value == None:
- return default_value
- else:
- return value
+ def oid_function(oid, default_value=None, cp_name=check_plugin_name):
+ value = snmp.get_single_oid(access_data, oid, cp_name,
do_snmp_scan=do_snmp_scan)
+ return default_value if value is None else value
result = scan_function(oid_function)
if result is not None and type(result) not in [ str, bool ]:
diff --git a/tests/pylint/pylintrc b/tests/pylint/pylintrc
index f91b997..37bf8c1 100644
--- a/tests/pylint/pylintrc
+++ b/tests/pylint/pylintrc
@@ -12,7 +12,6 @@ extension-pkg-whitelist=rrdtool,_ldap,netifaces,pymssql
[MESSAGES CONTROL]
disable=
- cell-var-from-loop,
inconsistent-return-statements,
missing-docstring,
no-else-return,