-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodeclimate-ansiblereview.py
executable file
·47 lines (44 loc) · 1.28 KB
/
codeclimate-ansiblereview.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/python
import yaml
import subprocess
try:
with open('.codeclimate.yml', 'r') as f:
doc = yaml.load(f)
except:
pass
else:
try:
standardsrepozip = doc['engines']['ansiblereview']['config']['rules_zip']
except:
pass
try:
workdir = doc['engines']['ansiblereview']['config']['work_dir']
except:
pass
try:
standards = doc['engines']['ansiblereview']['config']['standards_dir']
except:
pass
try:
lint = doc['engines']['ansiblereview']['config']['lint_dir']
except:
pass
try:
searchmethod = doc['engines']['ansiblereview']['config']['search_method']
except:
searchcommand = "git ls-files"
else:
if searchmethod == "find":
searchcommand = "find . -type f"
else:
searchcommand = "git ls-files"
try:
debug = doc['engines']['ansiblereview']['config']['debug']
except:
debug = ""
else:
debug = " -vv"
cmd = searchcommand + " | xargs /usr/src/app/ansible-review/bin/ansible-review -t -w " + workdir + " -g " + standardsrepozip + " -d " + standards + " -r " + lint + debug
ps = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
output = ps.communicate()[0]
print output