1#!/usr/bin/env python3
2#
3# Arm SCP/MCP Software
4# Copyright (c) 2021-2022, 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
15
16INCLUDE_DIRECTORIES = "tools/ unit_test/utils"
17
18
19def banner(text):
20    columns = 80
21    title = " {} ".format(text)
22    print("\n\n{}".format(title.center(columns, "*")))
23
24
25def main():
26    banner("Build and run PyCodeStyle tests")
27
28    result = subprocess.Popen(
29        "python -m pycodestyle {}".format(INCLUDE_DIRECTORIES),
30        shell=True,
31        stdout=subprocess.PIPE,
32        stderr=subprocess.PIPE)
33
34    (stdout, stderr) = result.communicate()
35
36    print(stdout.decode())
37
38    if result.returncode != 0:
39        print(stderr.decode())
40        print('FAILED')
41        return 1
42    print('SUCCESS')
43    return 0
44
45
46if __name__ == '__main__':
47    sys.exit(main())
48