forked from Vauxoo/pylint-conf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_sqa_check
executable file
·40 lines (36 loc) · 1.3 KB
/
run_sqa_check
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
#!/usr/bin/env python
import subprocess
import os
import sys
def main():
pylint_cfg_path = os.path.join( os.path.dirname(\
os.path.abspath(__file__)), 'conf')
pylint_cfg_fname = 'pylint_vauxoo.cfg'#TODO: Receive as params
#TODO: get params from terminal
if len(sys.argv) >= 2:
workdir = sys.argv[1]
else:
workdir = os.getcwd()
#Fixed pylint path. More info:
# https://www.mail-archive.com/code-quality@python.org/msg00294.html
to_delete = False
fpath_main_init = os.path.join(workdir, '__init__.py')
if not os.path.isfile( fpath_main_init ):
to_delete = True
try:
if to_delete:
open(fpath_main_init, "w")
os.environ['PYTHONPATH'] += ":"+workdir #TODO: win compatibility
pylint_cfg_fname_path = os.path.join( pylint_cfg_path, pylint_cfg_fname)
if os.path.isfile( pylint_cfg_fname_path ):
cmd = "pylint --rcfile=%s %s"%(pylint_cfg_fname_path, workdir)
print "cmd", cmd#TODO: log info
subprocess.check_call(cmd, shell=True)
else:
print "File not exists [%s]"%( pylint_cfg_fname_path )#TODO: log error
finally:
if to_delete:
os.remove( fpath_main_init )
return 0
if __name__ == '__main__':
exit(main())