From 958bf404894c7918a912986c24c78b1f6d6fa369 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Fri, 13 Apr 2018 23:29:35 +0800 Subject: add lint tool to check python3 shebang --- contrib/devtools/lint-python-shebang.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 contrib/devtools/lint-python-shebang.sh diff --git a/contrib/devtools/lint-python-shebang.sh b/contrib/devtools/lint-python-shebang.sh new file mode 100755 index 0000000000..f5c5971c03 --- /dev/null +++ b/contrib/devtools/lint-python-shebang.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# Shebang must use python3 (not python or python2) +EXIT_CODE=0 +for PYTHON_FILE in $(git ls-files -- "*.py"); do + if [[ $(head -c 2 "${PYTHON_FILE}") == "#!" && + $(head -n 1 "${PYTHON_FILE}") != "#!/usr/bin/env python3" ]]; then + echo "Missing shebang \"#!/usr/bin/env python3\" in ${PYTHON_FILE} (do not use python or python2)" + EXIT_CODE=1 + fi +done +exit ${EXIT_CODE} -- cgit v1.2.3 From 2bff472992401b9fecf89622a0151e6fcdab3707 Mon Sep 17 00:00:00 2001 From: John Newbery Date: Fri, 13 Apr 2018 23:37:53 +0800 Subject: [contrib] convert test-security-check to python3 --- contrib/devtools/test-security-check.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contrib/devtools/test-security-check.py b/contrib/devtools/test-security-check.py index 22f5ee20f7..ee87c8bab4 100755 --- a/contrib/devtools/test-security-check.py +++ b/contrib/devtools/test-security-check.py @@ -1,11 +1,10 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # Copyright (c) 2015-2017 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. ''' Test script for security-check.py ''' -from __future__ import division,print_function import subprocess import unittest @@ -22,7 +21,7 @@ def write_testcode(filename): def call_security_check(cc, source, executable, options): subprocess.check_call([cc,source,'-o',executable] + options) - p = subprocess.Popen(['./security-check.py',executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) + p = subprocess.Popen(['./security-check.py',executable], stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True) (stdout, stderr) = p.communicate() return (p.returncode, stdout.rstrip()) -- cgit v1.2.3