diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-11-15 18:45:33 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-11-15 18:45:33 +0000 |
commit | 97e923f9f084f3b8aa1f8a8ee7cccbb31821eea4 (patch) | |
tree | 908da16226aadb660ae177c672dd6b0a1c920938 | |
parent | 0886c91f7f62aa55042699c5a3b6b4629eb79010 (diff) | |
parent | b9006f94efcbd7fd302a318ad6427a1ab57f8a3f (diff) | |
download | repohooks-97e923f9f084f3b8aa1f8a8ee7cccbb31821eea4.tar.gz |
Merge "pylint: handle missing pylint better"
-rwxr-xr-x | tools/pylint.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/pylint.py b/tools/pylint.py index 6091c1d..1c8e6f7 100755 --- a/tools/pylint.py +++ b/tools/pylint.py @@ -19,12 +19,15 @@ from __future__ import print_function import argparse +import errno import os import sys + DEFAULT_PYLINTRC_PATH = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'pylintrc') + def get_parser(): """Return a command line parser.""" parser = argparse.ArgumentParser(description=__doc__) @@ -62,7 +65,17 @@ def main(argv): if opts.init_hook: cmd += ['--init-hook', opts.init_hook] - os.execvp(cmd[0], cmd) + try: + os.execvp(cmd[0], cmd) + except OSError as e: + if e.errno == errno.ENOENT: + print('%s: unable to run `%s`: %s' % (__file__, cmd[0], e), + file=sys.stderr) + print('%s: Try installing pylint: sudo apt-get install pylint' % + (__file__,), file=sys.stderr) + return 1 + else: + raise if __name__ == '__main__': |