1#!/usr/bin/env python3 2# 3# Arm SCP/MCP Software 4# Copyright (c) 2021-2024, Arm Limited and Contributors. All rights reserved. 5# 6# SPDX-License-Identifier: BSD-3-Clause 7 8""" 9Check pycodestyle 10This script runs pycodestyle to check all python scripts. 11""" 12 13import sys 14import subprocess 15from utils import banner 16 17INCLUDE_DIRECTORIES = 'tools/' 18 19 20def run(): 21 print(banner('Run PyCodeStyle tests')) 22 23 result = subprocess.Popen( 24 'python -m pycodestyle {}'.format(INCLUDE_DIRECTORIES), 25 shell=True, 26 stdout=subprocess.PIPE, 27 stderr=subprocess.PIPE) 28 29 (stdout, stderr) = result.communicate() 30 31 print(stdout.decode()) 32 33 if result.returncode != 0: 34 print(stderr.decode()) 35 print('Run PyCodeStyle tests failed.') 36 return False 37 38 print('Run PyCodeStyle tests succedded.') 39 return True 40 41 42def main(): 43 return 0 if run() else 1 44 45 46if __name__ == '__main__': 47 sys.exit(main()) 48