Module: check_mk
Branch: master
Commit: 1dc70cadc81a1dff5dd6cbb78b904a3e835f14b2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1dc70cadc81a1d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 22 18:25:14 2016 +0200
pylint-web is now also checking CEE web code; Ensure equal branches in cmk/cee repos while
checking
---
pylint/pylint-checks | 1 +
pylint/pylint-modules | 1 +
pylint/pylint-web | 42 +++++++++++++++++++++++++-----------------
pylint/pylint_cmk.py | 12 +++++++++++-
4 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/pylint/pylint-checks b/pylint/pylint-checks
index 270bfce..a331f88 100755
--- a/pylint/pylint-checks
+++ b/pylint/pylint-checks
@@ -5,6 +5,7 @@ import os
import sys
import pylint_cmk
+pylint_cmk.ensure_equal_branches()
base_path = pylint_cmk.get_test_dir()
f = file(base_path + "/cmk-checks.py", "w")
diff --git a/pylint/pylint-modules b/pylint/pylint-modules
index f25e504..b70e331 100755
--- a/pylint/pylint-modules
+++ b/pylint/pylint-modules
@@ -6,6 +6,7 @@ import sys
import tempfile
import pylint_cmk
+pylint_cmk.ensure_equal_branches()
base_path = pylint_cmk.get_test_dir()
f = file(base_path + "/cmk-modules.py", "w")
diff --git a/pylint/pylint-web b/pylint/pylint-web
index 6534d41..29ff5e3 100755
--- a/pylint/pylint-web
+++ b/pylint/pylint-web
@@ -1,12 +1,16 @@
#!/usr/bin/python
# encoding: utf-8
-import os, sys, shutil, glob
-import pylint_cmk
+import os
+import sys
+import glob
+import shutil
import tempfile
+import pylint_cmk
def get_web_plugin_dirs():
- plugin_dirs = sorted(os.listdir("../web/plugins"))
+ plugin_dirs = sorted(list(set(os.listdir("../web/plugins")
+ + os.listdir("../../cmc/web/plugins"))))
# icons are included from a plugin of views module. Move to the end to
# make them be imported after the views plugins. Same for perfometers.
@@ -17,16 +21,25 @@ def get_web_plugin_dirs():
return plugin_dirs
-cmk_branch = os.popen("git rev-parse --abbrev-ref HEAD").read().strip()
-cmc_branch = os.popen("cd ../../cmc ; git rev-parse --abbrev-ref
HEAD").read().strip()
-if cmk_branch != cmc_branch:
- sys.stderr.write("ERROR: Branches sind unterschiedlich (%s <> %s)\n"
%
- (cmk_branch, cmc_branch))
- sys.exit(1)
+def get_plugin_files(plugin_dir):
+ files = []
+
+ for path in [ "../web/plugins/"+plugin_dir,
+ "../../cmc/web/plugins/"+plugin_dir ]:
+ if os.path.exists(path):
+ files += [ (f, path) for f in os.listdir(path) ]
+
+ return sorted(files)
+
+pylint_cmk.ensure_equal_branches()
base_path = pylint_cmk.get_test_dir()
-modules = glob.glob("../web/htdocs/*.py") +
glob.glob("../../cmc/web/htdocs/*.py")
+# Make compiled files import eachother by default
+sys.path.insert(0, base_path)
+
+modules = glob.glob("../web/htdocs/*.py") \
+ + glob.glob("../../cmc/web/htdocs/*.py")
for module in modules:
print("Copy %s to test directory" % module)
@@ -35,14 +48,9 @@ for module in modules:
# Move the whole plugins code to their modules, then
# run pylint only on the modules
for plugin_dir in get_web_plugin_dirs():
- path = "../web/plugins/"+plugin_dir
- files = [ (f, path) for f in os.listdir(path) ]
-
- cmc_path = "../../cmc/web/plugins/"+plugin_dir
- if os.path.exists(cmc_path):
- files += [ (f, cmc_path) for f in os.listdir(cmc_path) ]
+ files = get_plugin_files(plugin_dir)
- for plugin_file, plugin_base in sorted(files):
+ for plugin_file, plugin_base in files:
plugin_path = plugin_base +"/"+plugin_file
if plugin_dir in ["icons","perfometer"]:
diff --git a/pylint/pylint_cmk.py b/pylint/pylint_cmk.py
index 90812bd..e8eed33 100644
--- a/pylint/pylint_cmk.py
+++ b/pylint/pylint_cmk.py
@@ -79,7 +79,8 @@ def get_test_dir():
def run_pylint(cfg_file, base_path):
cmd = "pylint --rcfile=\"%s\" %s/*.py" % (cfg_file, base_path)
print("Starting pylint with: %s" % cmd)
- exit_code = os.system(cmd) >> 8
+ exit_code = os.system(cmd)
+ print("Finished with exit code: %d" % exit_code)
if exit_code == 0:
print("Removing build path...")
@@ -87,3 +88,12 @@ def run_pylint(cfg_file, base_path):
return exit_code
+
+def ensure_equal_branches():
+ cmk_branch = os.popen("git rev-parse --abbrev-ref HEAD").read().strip()
+ cmc_branch = os.popen("cd ../../cmc ; "
+ "git rev-parse --abbrev-ref HEAD").read().strip()
+ if cmk_branch != cmc_branch:
+ sys.stderr.write("ERROR: Different branches (%s != %s)\n" %
+ (cmk_branch, cmc_branch))
+ sys.exit(1)