Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466

Dependencies:   ssd1331

Committer:
kadonotakashi
Date:
Thu Oct 11 02:27:46 2018 +0000
Revision:
3:f3764f852aa8
Parent:
0:8fdf9a60065b
Nucreo 446 + SSD1331 test version;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kadonotakashi 0:8fdf9a60065b 1 """A test that all code scores above a 9.25 in pylint"""
kadonotakashi 0:8fdf9a60065b 2
kadonotakashi 0:8fdf9a60065b 3 import subprocess
kadonotakashi 0:8fdf9a60065b 4 import re
kadonotakashi 0:8fdf9a60065b 5 import os.path
kadonotakashi 0:8fdf9a60065b 6
kadonotakashi 0:8fdf9a60065b 7 SCORE_REGEXP = re.compile(
kadonotakashi 0:8fdf9a60065b 8 r'^Your\ code\ has\ been\ rated\ at\ (\-?[0-9\.]+)/10')
kadonotakashi 0:8fdf9a60065b 9
kadonotakashi 0:8fdf9a60065b 10 TOOLS_ROOT = os.path.dirname(os.path.dirname(__file__))
kadonotakashi 0:8fdf9a60065b 11
kadonotakashi 0:8fdf9a60065b 12
kadonotakashi 0:8fdf9a60065b 13 def parse_score(pylint_output):
kadonotakashi 0:8fdf9a60065b 14 """Parse the score out of pylint's output as a float If the score is not
kadonotakashi 0:8fdf9a60065b 15 found, return 0.0.
kadonotakashi 0:8fdf9a60065b 16 """
kadonotakashi 0:8fdf9a60065b 17 for line in pylint_output.splitlines():
kadonotakashi 0:8fdf9a60065b 18 match = re.match(SCORE_REGEXP, line)
kadonotakashi 0:8fdf9a60065b 19 if match:
kadonotakashi 0:8fdf9a60065b 20 return float(match.group(1))
kadonotakashi 0:8fdf9a60065b 21 return 0.0
kadonotakashi 0:8fdf9a60065b 22
kadonotakashi 0:8fdf9a60065b 23 def execute_pylint(filename):
kadonotakashi 0:8fdf9a60065b 24 """Execute a pylint process and collect it's output
kadonotakashi 0:8fdf9a60065b 25 """
kadonotakashi 0:8fdf9a60065b 26 process = subprocess.Popen(
kadonotakashi 0:8fdf9a60065b 27 ["pylint", filename],
kadonotakashi 0:8fdf9a60065b 28 stdout=subprocess.PIPE,
kadonotakashi 0:8fdf9a60065b 29 stderr=subprocess.PIPE
kadonotakashi 0:8fdf9a60065b 30 )
kadonotakashi 0:8fdf9a60065b 31 stout, sterr = process.communicate()
kadonotakashi 0:8fdf9a60065b 32 status = process.poll()
kadonotakashi 0:8fdf9a60065b 33 return status, stout, sterr
kadonotakashi 0:8fdf9a60065b 34
kadonotakashi 0:8fdf9a60065b 35 FILES = ["build_api.py", "config.py", "colorize.py", "detect_targets.py",
kadonotakashi 0:8fdf9a60065b 36 "hooks.py", "libraries.py", "memap.py", "options.py", "paths.py",
kadonotakashi 0:8fdf9a60065b 37 "targets.py", "test/pylint.py"]
kadonotakashi 0:8fdf9a60065b 38
kadonotakashi 0:8fdf9a60065b 39 if __name__ == "__main__":
kadonotakashi 0:8fdf9a60065b 40 for python_module in FILES:
kadonotakashi 0:8fdf9a60065b 41 _, stdout, stderr = execute_pylint(os.path.join(TOOLS_ROOT,
kadonotakashi 0:8fdf9a60065b 42 python_module))
kadonotakashi 0:8fdf9a60065b 43 score = parse_score(stdout)
kadonotakashi 0:8fdf9a60065b 44 if score < 9.25:
kadonotakashi 0:8fdf9a60065b 45 print(stdout)
kadonotakashi 0:8fdf9a60065b 46
kadonotakashi 0:8fdf9a60065b 47
kadonotakashi 0:8fdf9a60065b 48