Module: check_mk
Branch: master
Commit: 863dcc0b950b020819ee43e523169faf2936d34a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=863dcc0b950b02…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Apr 22 18:59:35 2016 +0200
pylint: Writing output to log file when run in build mode
---
pylint/.gitignore | 1 +
pylint/Makefile | 12 +++++++-----
pylint/pylint.log | 4 ----
pylint/pylint_cmk.py | 23 ++++++++++++++++++++---
4 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/pylint/.gitignore b/pylint/.gitignore
new file mode 100644
index 0000000..3023087
--- /dev/null
+++ b/pylint/.gitignore
@@ -0,0 +1 @@
+pylint.log
diff --git a/pylint/Makefile b/pylint/Makefile
index 16c4f70..1b8394e 100644
--- a/pylint/Makefile
+++ b/pylint/Makefile
@@ -9,15 +9,17 @@ help:
all: modules web checks
modules:
- ./pylint-modules
+ ./pylint-modules || true
web:
- ./pylint-web
+ ./pylint-web || true
checks:
- ./pylint-checks
-
+ ./pylint-checks || true
build:
export TERM="linux" ; \
- $(MAKE) all > pylint.log
+ export PYLINT_ARGS="--output-format=parseable" ; \
+ export PYLINT_OUTPUT="pylint.log" ; \
+ echo -n > pylint.log ; \
+ $(MAKE) all
diff --git a/pylint/pylint.log b/pylint/pylint.log
deleted file mode 100644
index 94e118a..0000000
--- a/pylint/pylint.log
+++ /dev/null
@@ -1,4 +0,0 @@
-make[1]: Entering directory '/home/lm/git/check_mk/pylint'
-./pylint-modules
-Makefile:12: recipe for target 'modules' failed
-make[1]: Leaving directory '/home/lm/git/check_mk/pylint'
diff --git a/pylint/pylint_cmk.py b/pylint/pylint_cmk.py
index e8eed33..640ef24 100644
--- a/pylint/pylint_cmk.py
+++ b/pylint/pylint_cmk.py
@@ -2,9 +2,12 @@
# Library for pylint checks of Check_MK
import os
+import sys
import shutil
+import subprocess
import tempfile
+
def ordered_module_files():
modules = [
"../defaults",
@@ -77,9 +80,23 @@ 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)
+ pylint_args = os.environ.get("PYLINT_ARGS", "")
+ if pylint_args:
+ pylint_args += " "
+ pylint_output = os.environ.get("PYLINT_OUTPUT")
+
+ cmd = "pylint --rcfile=\"%s\" %s%s/*.py" % (cfg_file,
pylint_args, base_path)
+ print("Running pylint with: %s" % cmd)
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
+ stdout = p.communicate()[0]
+
+ if stdout.strip():
+ if pylint_output:
+ file(pylint_output, "a").write(stdout)
+ else:
+ print(stdout)
+
+ exit_code = p.returncode
print("Finished with exit code: %d" % exit_code)
if exit_code == 0: