Keep compatibility with python versions prior to 3.5

Signed-off-by: Yuto Takano <yuto.takano@arm.com>
This commit is contained in:
Darryl Green 2018-05-17 14:14:50 +01:00 committed by Yuto Takano
parent a783d9c5ef
commit 6c79b5dce7

View file

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python2
""" """
This file is part of Mbed TLS (https://tls.mbed.org) This file is part of Mbed TLS (https://tls.mbed.org)
@ -146,20 +146,17 @@ class NameCheck(object):
try: try:
shutil.copy("include/mbedtls/config.h", shutil.copy("include/mbedtls/config.h",
"include/mbedtls/config.h.bak") "include/mbedtls/config.h.bak")
subprocess.run( subprocess.check_output(
["perl", "scripts/config.pl", "full"], ["perl", "scripts/config.pl", "full"],
encoding=sys.stdout.encoding, universal_newlines=True,
check=True
) )
my_environment = os.environ.copy() my_environment = os.environ.copy()
my_environment["CFLAGS"] = "-fno-asynchronous-unwind-tables" my_environment["CFLAGS"] = "-fno-asynchronous-unwind-tables"
subprocess.run( subprocess.check_output(
["make", "clean", "lib"], ["make", "clean", "lib"],
env=my_environment, env=my_environment,
encoding=sys.stdout.encoding, universal_newlines=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
check=True
) )
shutil.move("include/mbedtls/config.h.bak", shutil.move("include/mbedtls/config.h.bak",
"include/mbedtls/config.h") "include/mbedtls/config.h")
@ -167,13 +164,11 @@ class NameCheck(object):
for lib in ["library/libmbedcrypto.a", for lib in ["library/libmbedcrypto.a",
"library/libmbedtls.a", "library/libmbedtls.a",
"library/libmbedx509.a"]: "library/libmbedx509.a"]:
nm_output += subprocess.run( nm_output += subprocess.check_output(
["nm", "-og", lib], ["nm", "-og", lib],
encoding=sys.stdout.encoding, universal_newlines=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, stderr=subprocess.STDOUT,
check=True )
).stdout
for line in nm_output.splitlines(): for line in nm_output.splitlines():
if not re.match(r"^\S+: +U |^$|^\S+:$", line): if not re.match(r"^\S+: +U |^$|^\S+:$", line):
symbol = re.match(self.symbol_pattern, line) symbol = re.match(self.symbol_pattern, line)
@ -182,10 +177,9 @@ class NameCheck(object):
else: else:
self.log.error(line) self.log.error(line)
self.symbols.sort() self.symbols.sort()
subprocess.run( subprocess.check_output(
["make", "clean"], ["make", "clean"],
encoding=sys.stdout.encoding, universal_newlines=True,
check=True
) )
except subprocess.CalledProcessError as error: except subprocess.CalledProcessError as error:
self.log.error(error) self.log.error(error)