Module: check_mk
Branch: master
Commit: e418636fbec79bb703aa43bc68332efc8b3aeda4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e418636fbec79b…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Jul 3 14:07:29 2018 +0200
Fixed and enabled invalid-encoded-data warnings.
Change-Id: I84b3d6c37e810eb858046da7116455fdb7f055f7
---
tests/pylint/pylintrc | 1 -
tests/pylint/test_pylint_bakery_plugins.py | 12 +++++------
tests/pylint/test_pylint_check_plugins.py | 19 +++++++++---------
tests/pylint/test_pylint_inventory_plugins.py | 29 +++++++++++++--------------
tests/pylint/test_pylint_web.py | 10 ++++-----
tests/testlib/pylint_cmk.py | 2 +-
web/htdocs/availability.py | 8 ++++----
7 files changed, 37 insertions(+), 44 deletions(-)
diff --git a/tests/pylint/pylintrc b/tests/pylint/pylintrc
index f5e6fd4..3dc4418 100644
--- a/tests/pylint/pylintrc
+++ b/tests/pylint/pylintrc
@@ -40,7 +40,6 @@ disable=
global-statement,
global-variable-undefined,
inconsistent-return-statements,
- invalid-encoded-data,
invalid-name,
keyword-arg-before-vararg,
len-as-condition,
diff --git a/tests/pylint/test_pylint_bakery_plugins.py
b/tests/pylint/test_pylint_bakery_plugins.py
index 517095e..fa9a075 100755
--- a/tests/pylint/test_pylint_bakery_plugins.py
+++ b/tests/pylint/test_pylint_bakery_plugins.py
@@ -7,15 +7,13 @@ from testlib import repo_path, cmc_path
import testlib.pylint_cmk as pylint_cmk
def test_pylint_bakery_plugins(pylint_test_dir):
- f = file(pylint_test_dir + "/cmk-bakery-plugins.py", "w")
+ with open(pylint_test_dir + "/cmk-bakery-plugins.py", "w") as f:
- pylint_cmk.add_file(f, os.path.realpath(os.path.join(cmc_path(),
"cmk_base/cee/agent_bakery_plugins.py")))
+ pylint_cmk.add_file(f, os.path.realpath(os.path.join(cmc_path(),
"cmk_base/cee/agent_bakery_plugins.py")))
- # Also add bakery plugins
- for path in pylint_cmk.check_files(os.path.join(cmc_path(),
"agents/bakery")):
- pylint_cmk.add_file(f, path)
-
- f.close()
+ # Also add bakery plugins
+ for path in pylint_cmk.check_files(os.path.join(cmc_path(),
"agents/bakery")):
+ pylint_cmk.add_file(f, path)
exit_code = pylint_cmk.run_pylint(pylint_test_dir)
assert exit_code == 0, "PyLint found an error in agent bakery plugins"
diff --git a/tests/pylint/test_pylint_check_plugins.py
b/tests/pylint/test_pylint_check_plugins.py
index a259872..956f2ef 100755
--- a/tests/pylint/test_pylint_check_plugins.py
+++ b/tests/pylint/test_pylint_check_plugins.py
@@ -8,10 +8,11 @@ from testlib import repo_path, cmc_path
import testlib.pylint_cmk as pylint_cmk
def test_pylint_checks(pylint_test_dir):
- f = file(pylint_test_dir + "/cmk-checks.py", "w")
+ with open(pylint_test_dir + "/cmk-checks.py", "w") as f:
- # Fake data structures where checks register (See cmk_base/checks.py)
- f.write("""
+ # Fake data structures where checks register (See cmk_base/checks.py)
+ f.write("""
+# -*- encoding: utf-8 -*-
check_info = {}
check_includes = {}
precompile_params = {}
@@ -24,14 +25,12 @@ active_check_info = {}
special_agent_info = {}
""")
- # add the modules
- pylint_cmk.add_file(f, repo_path() + "/cmk_base/check_api.py")
+ # add the modules
+ pylint_cmk.add_file(f, repo_path() + "/cmk_base/check_api.py")
- # Now add the checks
- for path in pylint_cmk.check_files(repo_path() + "/checks"):
- pylint_cmk.add_file(f, path)
-
- f.close()
+ # Now add the checks
+ for path in pylint_cmk.check_files(repo_path() + "/checks"):
+ pylint_cmk.add_file(f, path)
exit_code = pylint_cmk.run_pylint(pylint_test_dir)
assert exit_code == 0, "PyLint found an error in checks, inventory " \
diff --git a/tests/pylint/test_pylint_inventory_plugins.py
b/tests/pylint/test_pylint_inventory_plugins.py
index ed2b5c7..28b8e9c 100755
--- a/tests/pylint/test_pylint_inventory_plugins.py
+++ b/tests/pylint/test_pylint_inventory_plugins.py
@@ -7,10 +7,11 @@ from testlib import repo_path
import testlib.pylint_cmk as pylint_cmk
def test_pylint_inventory_plugins(pylint_test_dir):
- f = file(pylint_test_dir + "/cmk-inventory-plugins.py", "w")
+ with open(pylint_test_dir + "/cmk-inventory-plugins.py", "w") as
f:
- # Fake data structures where checks register (See cmk_base/checks.py)
- f.write("""
+ # Fake data structures where checks register (See cmk_base/checks.py)
+ f.write("""
+# -*- encoding: utf-8 -*-
check_info = {}
check_includes = {}
precompile_params = {}
@@ -37,21 +38,19 @@ def inv_tree(path, default_value=None):
return node
""")
- # add the modules
- pylint_cmk.add_file(f, repo_path() + "/cmk_base/check_api.py")
+ # add the modules
+ pylint_cmk.add_file(f, repo_path() + "/cmk_base/check_api.py")
- # add the modules
- pylint_cmk.add_file(f, repo_path() + "/cmk_base/inventory_plugins.py")
+ # add the modules
+ pylint_cmk.add_file(f, repo_path() + "/cmk_base/inventory_plugins.py")
- # Now add the checks
- for path in pylint_cmk.check_files(repo_path() + "/checks"):
- pylint_cmk.add_file(f, path)
+ # Now add the checks
+ for path in pylint_cmk.check_files(repo_path() + "/checks"):
+ pylint_cmk.add_file(f, path)
- # Now add the inventory plugins
- for path in pylint_cmk.check_files(repo_path() + "/inventory"):
- pylint_cmk.add_file(f, path)
-
- f.close()
+ # Now add the inventory plugins
+ for path in pylint_cmk.check_files(repo_path() + "/inventory"):
+ pylint_cmk.add_file(f, path)
exit_code = pylint_cmk.run_pylint(pylint_test_dir)
assert exit_code == 0, "PyLint found an error in inventory plugins"
diff --git a/tests/pylint/test_pylint_web.py b/tests/pylint/test_pylint_web.py
index 50af9e3..f58b200 100755
--- a/tests/pylint/test_pylint_web.py
+++ b/tests/pylint/test_pylint_web.py
@@ -45,9 +45,8 @@ def test_pylint_web(pylint_test_dir):
for module in modules:
print("Copy %s to test directory" % module)
- f = open(pylint_test_dir + "/" + os.path.basename(module),
"w")
- pylint_cmk.add_file(f, module)
- f.close()
+ with open(pylint_test_dir + "/" + os.path.basename(module),
"w") as f:
+ pylint_cmk.add_file(f, module)
# Move the whole plugins code to their modules, then
# run pylint only on the modules
@@ -67,9 +66,8 @@ def test_pylint_web(pylint_test_dir):
module_name = plugin_dir
print("[%s] add %s" % (module_name, plugin_path))
- module = file(pylint_test_dir + "/" + module_name +
".py", "a")
- pylint_cmk.add_file(module, plugin_path)
- module.close()
+ with open(pylint_test_dir + "/" + module_name + ".py",
"a") as module:
+ pylint_cmk.add_file(module, plugin_path)
exit_code = pylint_cmk.run_pylint(pylint_test_dir)
assert exit_code == 0, "PyLint found an error in the web code"
diff --git a/tests/testlib/pylint_cmk.py b/tests/testlib/pylint_cmk.py
index 3e278cf..6f3d524 100644
--- a/tests/testlib/pylint_cmk.py
+++ b/tests/testlib/pylint_cmk.py
@@ -29,7 +29,7 @@ def add_file(f, path):
# in the build system.
relpath = os.path.relpath(os.path.realpath(path),
os.path.dirname(os.path.dirname(os.getcwd())))
- f.write("\n")
+ f.write("# -*- encoding: utf-8 -*-")
f.write("#\n")
f.write("# ORIG-FILE: " + relpath + "\n")
f.write("#\n")
diff --git a/web/htdocs/availability.py b/web/htdocs/availability.py
index 6f17c8b..b106de1 100644
--- a/web/htdocs/availability.py
+++ b/web/htdocs/availability.py
@@ -1128,7 +1128,7 @@ def melt_short_intervals(entries, duration, dont_merge):
# {
# "from" : 1238288548,
# "until" : 1238292845,
-# "text" : u"Das ist ein Text über mehrere Zeilen, oder
was weiß ich",
+# "text" : u"Das ist ein Text ÃŒber mehrere Zeilen, oder
was weià ich",
# "date" : 12348854885, # Time of entry
# "author" : "mk",
# "downtime" : True, # Can also be False or None or missing. None
is like missing
@@ -1204,9 +1204,9 @@ def delete_annotation(annotations, site_host_svc, fromtime,
untiltime):
# When grouping is enabled, this function is called once for each group
# TODO: range_title sollte hier ueberfluessig sein
# TODO: Hier jetzt nicht direkt HTML erzeugen, sondern eine saubere
-# Datenstruktur füllen, welche die Daten so repräsentiert, dass sie
-# nur noch 1:1 dargestellt werden müssen.
-# Beispiel für einen Rückgabewert:
+# Datenstruktur fÌllen, welche die Daten so reprÀsentiert, dass sie
+# nur noch 1:1 dargestellt werden mÃŒssen.
+# Beispiel fÃŒr einen RÃŒckgabewert:
# {
# "title" : "Hostgroup foobar",
# "headers" : [ "OK, "CRIT", "Downtime" ],