diff options
author | Jack Lloyd <[email protected]> | 2017-07-31 11:11:11 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-07-31 11:11:11 -0400 |
commit | f215d4f7a6a6d8fe1d77773a043c8f75ec7bd646 (patch) | |
tree | 3cbe23a1d36166b0bb73bc6b3a42cb7ba6c29a50 /src | |
parent | bf1efdb909118a309bffbab8f0cd513842d59092 (diff) | |
parent | 2a3c0f42f1ce0854194ec347761f102e26eb9575 (diff) |
Merge GH #1134 Run pylint on install.py
Diffstat (limited to 'src')
-rwxr-xr-x | src/scripts/ci/travis/lint.sh | 19 | ||||
-rwxr-xr-x | src/scripts/install.py | 39 |
2 files changed, 35 insertions, 23 deletions
diff --git a/src/scripts/ci/travis/lint.sh b/src/scripts/ci/travis/lint.sh index 7351eb2aa..df9288b36 100755 --- a/src/scripts/ci/travis/lint.sh +++ b/src/scripts/ci/travis/lint.sh @@ -2,20 +2,29 @@ set -ev which shellcheck > /dev/null && shellcheck "$0" # Run shellcheck on this if available +shopt -s expand_aliases + # Disabled rules in Python 2 only # superfluous-parens: needed for print statements # too-many-locals: variable counting differs from pylint3 +alias python2_pylint='python2 -m pylint --disable=superfluous-parens,too-many-locals' +alias python3_pylint='python3 -m pylint' echo "travis_fold:start:pylint_configure" -python3 -m pylint configure.py -python2 -m pylint --disable=superfluous-parens,too-many-locals configure.py +python2_pylint configure.py +python3_pylint configure.py +echo "travis_fold:end:pylint_configure" + +echo "travis_fold:start:pylint_install" +python2_pylint src/scripts/install.py +python3_pylint src/scripts/install.py echo "travis_fold:end:pylint_configure" echo "travis_fold:start:pylint_python_unittests" -python3 -m pylint src/scripts/python_uniitests.py +python3_pylint src/scripts/python_uniitests.py echo "travis_fold:end:pylint_python_unittests" echo "travis_fold:start:pylint_botanpy" -python3 -m pylint src/python/botan2.py -python2 -m pylint --disable=superfluous-parens,too-many-locals src/python/botan2.py +python2_pylint src/python/botan2.py +python3_pylint src/python/botan2.py echo "travis_fold:end:pylint_botanpy" diff --git a/src/scripts/install.py b/src/scripts/install.py index a92cd43eb..601502657 100755 --- a/src/scripts/install.py +++ b/src/scripts/install.py @@ -11,7 +11,7 @@ Botan is released under the Simplified BSD License (see license.txt) import errno import json import logging -import optparse +import optparse # pylint: disable=deprecated-module import os import shutil import string @@ -63,7 +63,7 @@ def parse_command_line(args): return (options, args) -def makedirs(dirname, exist_ok = True): +def makedirs(dirname, exist_ok=True): try: logging.debug('Creating directory %s' % (dirname)) os.makedirs(dirname) @@ -80,22 +80,24 @@ def force_symlink(target, linkname): raise e os.symlink(target, linkname) -def main(args = None): - if args is None: - args = sys.argv - - logging.basicConfig(stream = sys.stdout, - format = '%(levelname) 7s: %(message)s') - - (options, args) = parse_command_line(args) - - exe_mode = 0o777 - +def calculate_exec_mode(options): + out = 0o777 if 'umask' in os.__dict__: umask = int(options.umask, 8) logging.debug('Setting umask to %s' % oct(umask)) os.umask(int(options.umask, 8)) - exe_mode &= (umask ^ 0o777) + out &= (umask ^ 0o777) + return out + +def main(args): + # pylint: disable=too-many-locals,too-many-branches,too-many-statements + + logging.basicConfig(stream=sys.stdout, + format='%(levelname) 7s: %(message)s') + + (options, args) = parse_command_line(args) + + exe_mode = calculate_exec_mode(options) def copy_file(src, dst): logging.debug('Copying %s to %s' % (src, dst)) @@ -172,8 +174,8 @@ def main(args = None): os.path.join(lib_dir, soname_base)) else: soname_patch = process_template('%{soname_patch}') - soname_abi = process_template('%{soname_abi}') - soname_base = process_template('%{soname_base}') + soname_abi = process_template('%{soname_abi}') + soname_base = process_template('%{soname_base}') copy_executable(os.path.join(out_dir, soname_patch), os.path.join(lib_dir, soname_patch)) @@ -229,11 +231,12 @@ def main(args = None): copy_file(os.path.join(cfg['base_dir'], 'news.rst'), os.path.join(target_doc_dir, 'news.txt')) logging.info('Botan %s installation complete', cfg['version']) + return 0 if __name__ == '__main__': try: - sys.exit(main()) - except Exception as e: + sys.exit(main(sys.argv)) + except Exception as e: # pylint: disable=broad-except logging.error('Failure: %s' % (e)) import traceback logging.info(traceback.format_exc()) |