--- a/checker.py Sun Jul 24 09:08:17 2016 +0800
+++ b/checker.py Sun Jul 24 09:24:14 2016 +0800
from candolint.utils import rel, timestamp
-def run_ignore_codes(fn, args, codes):
+def run_ignore_codes(fn, args, codes, **kwargs):
+ return fn(args, **kwargs)
except CalledProcessError as e:
if e.returncode not in codes:
-def run(args, silent=False, get_output=False, ignore_codes=None):
+def run(args, silent=False, get_output=False, ignore_codes=None, env=None):
+ full_env = os.environ.copy()
print('$ ' + ' '.join(args))
- result = run_ignore_codes(fn, args, ignore_codes)
+ result = run_ignore_codes(fn, args, ignore_codes, env=full_env)
+ result = fn(args, env=full_env)
+def combined_env(lenv, penv):
def git_clone(url, dest):
return run(['git', 'clone', url, dest])
- if 'version' in lc and not run(lc['exec'] + lc['version']):
+ env = combined_env(lc.get('env'), linter.get('env'))
+ if not run(lc['exec'] + lc['version'], env=env):
print('# C&O linters installed: {}'.format(' '.join(linter_config.keys())))
flags = lc.get('flags', []) + linter.get('flags', [])
pf = lc.get('post_flags', []) + linter.get('post_flags', [])
codes = lc.get('codes', (1,))
- if not run(cmd + flags + [f] + pf, ignore_codes=codes):
+ env = combined_env(lc.get('env'), linter.get('env'))
+ if not run(cmd + flags + [f] + pf, ignore_codes=codes, env=env):