Module: check_mk
Branch: master
Commit: 4cd547f7aecc024cdc1700d25fcbd821e7acf5d6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4cd547f7aecc02…
Author: Óscar Nájera <on(a)mathias-kettner.de>
Date: Wed Nov 14 14:49:17 2018 +0100
Fix idiomatic typecheck agents,bin
CMK-837
Change-Id: I043ea185f4a5a07eff37dfb384e63eaa875a8e1d
---
agents/plugins/mk_logwatch | 2 +-
agents/plugins/mk_sap | 2 +-
agents/special/agent_jolokia | 4 ++--
agents/special/agent_netapp | 6 +++---
agents/special/agent_siemens_plc | 4 ++--
agents/special/agent_vsphere | 2 +-
agents/special/agent_vsphere.pysphere | 6 +++---
bin/livedump | 2 +-
bin/mkbench | 2 +-
9 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/agents/plugins/mk_logwatch b/agents/plugins/mk_logwatch
index 5913e89..0a8d79e 100755
--- a/agents/plugins/mk_logwatch
+++ b/agents/plugins/mk_logwatch
@@ -433,7 +433,7 @@ def process_logfile(logfile, patterns, opt, status):
# Check for continuation lines
for cont_pattern in cont_patterns:
- if type(cont_pattern) == int: # add that many lines
+ if isinstance(cont_pattern, int): # add that many lines
for _unused_x in range(cont_pattern):
cont_line, pushed_back_line = next_line(file_handle,
pushed_back_line)
if cont_line is None: # end of file
diff --git a/agents/plugins/mk_sap b/agents/plugins/mk_sap
index 3904a43..01f0fe7 100755
--- a/agents/plugins/mk_sap
+++ b/agents/plugins/mk_sap
@@ -152,7 +152,7 @@ config_file = MK_CONFDIR + '/sap.cfg'
cfg = {}
if os.path.exists(config_file):
execfile(config_file)
- if type(cfg) == dict:
+ if isinstance(cfg, dict):
cfg = [cfg]
else:
cfg = [local_cfg]
diff --git a/agents/special/agent_jolokia b/agents/special/agent_jolokia
index 455b714..d79b092 100755
--- a/agents/special/agent_jolokia
+++ b/agents/special/agent_jolokia
@@ -184,8 +184,8 @@ def fetch_var(protocol, server, port, path, suburi, cert_path,
itemspec):
# convert single values into lists of items in
# case value is a 1-levelled or 2-levelled dict
def make_item_list(path, value, itemspec):
- if type(value) != dict:
- if type(value) == str:
+ if not isinstance(value, dict):
+ if isinstance(value, str):
value = value.replace(r'\/', '/')
return [(path, value)]
else:
diff --git a/agents/special/agent_netapp b/agents/special/agent_netapp
index 60fe4dd..38c37e8 100755
--- a/agents/special/agent_netapp
+++ b/agents/special/agent_netapp
@@ -314,7 +314,7 @@ else:
class NetAppNode(object):
def __init__(self, xml_element):
- if type(xml_element) == str:
+ if isinstance(xml_element, str):
xml_element = ET.Element(xml_element)
self.node = xml_element
self.element = self
@@ -437,7 +437,7 @@ def create_dict(instances, custom_key=None, is_counter=True):
values[node.element["name"]] =
node.element["content"] or ""
if custom_key:
- if type(custom_key) == list:
+ if isinstance(custom_key, list):
tokens = []
for name in custom_key:
tokens.append(values[name])
@@ -483,7 +483,7 @@ def format_config(instances,
collect_values(node)
line = []
- if type(config_key) == list:
+ if isinstance(config_key, list):
instance_key = []
for entry in config_key:
instance_key.append(values.get(entry))
diff --git a/agents/special/agent_siemens_plc b/agents/special/agent_siemens_plc
index eb6e8f1..c5a2286 100755
--- a/agents/special/agent_siemens_plc
+++ b/agents/special/agent_siemens_plc
@@ -202,7 +202,7 @@ for device in devices:
start_address = None
end_address = None
for area, (byte, bit), datatype, valuetype, ident in device['values']:
- if type(datatype) == tuple:
+ if isinstance(datatype, tuple):
size = datatype[1]
else:
size = datatypes[datatype][0]
@@ -226,7 +226,7 @@ for device in devices:
# Now loop all values to be fetched and extract the data
# from the bytes fetched above
for (area_name, db_number), (byte, bit), datatype, valuetype, ident in
device['values']:
- if type(datatype) == tuple:
+ if isinstance(datatype, tuple):
typename, size = datatype
parse_func = datatypes[typename][1]
else:
diff --git a/agents/special/agent_vsphere b/agents/special/agent_vsphere
index e4e8d02..4be5696 100755
--- a/agents/special/agent_vsphere
+++ b/agents/special/agent_vsphere
@@ -987,7 +987,7 @@ def write_output(vsphere_output, opt_agent, host):
sys.stdout.write(win_agent_output)
for line in vsphere_output:
- sys.stdout.write((line.encode("utf-8") if type(line) == unicode else
line) + "\n")
+ sys.stdout.write((line.encode("utf-8") if isinstance(line, unicode)
else line) + "\n")
sys.stdout.flush()
diff --git a/agents/special/agent_vsphere.pysphere
b/agents/special/agent_vsphere.pysphere
index 8cfeab6..69cdf15 100755
--- a/agents/special/agent_vsphere.pysphere
+++ b/agents/special/agent_vsphere.pysphere
@@ -303,11 +303,11 @@ def dump(x, indent=""):
print indent + k
dump_object(v, indent + " ")
- elif type(value) == str:
+ elif isinstance(value, str):
print indent + value
elif is_dict:
dump_dict(value, indent)
- elif type(value) == list:
+ elif isinstance(value, list):
dump_list(value, indent)
else:
debug(value)
@@ -666,7 +666,7 @@ def output_mors(what, properties, direct=False):
running_on = ''
power_state = ''
for name, value in items:
- if type(value) == tuple:
+ if isinstance(value, tuple):
sections.append(value)
else:
if name == 'runtime.host' and value:
diff --git a/bin/livedump b/bin/livedump
index 9b98e1b..60b99ce 100755
--- a/bin/livedump
+++ b/bin/livedump
@@ -72,7 +72,7 @@ define timeperiod {
def encode_row(row):
for key, val in row.items():
- if type(val) == unicode:
+ if isinstance(val, unicode):
row[key] = val.encode("utf-8")
diff --git a/bin/mkbench b/bin/mkbench
index fd8ec5c..da83d26 100755
--- a/bin/mkbench
+++ b/bin/mkbench
@@ -582,7 +582,7 @@ class TestRunner(threading.Thread):
result_msg = "Test case aborted: %s" % e
self.test.error(result_msg)
- if type(e) == MKFailTestCaseHighLatency:
+ if isinstance(e, MKFailTestCaseHighLatency):
self._increase_helpers()
else:
break