From 915fe23636919a3649b146bbc8dbc2e4e4710b3d Mon Sep 17 00:00:00 2001 From: Bill Ladwig Date: Thu, 25 Jan 2018 16:56:50 -0700 Subject: [PATCH] More py3 issues --- fortran/build_help/sub_sizes.py | 38 ++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/fortran/build_help/sub_sizes.py b/fortran/build_help/sub_sizes.py index 26feae1..4261977 100644 --- a/fortran/build_help/sub_sizes.py +++ b/fortran/build_help/sub_sizes.py @@ -1,28 +1,42 @@ import subprocess import os from string import Template +import sys def main(): print ("Running sub_sizes") try: result = subprocess.check_output(["./sizes"]) - except WindowsError: + except: result = subprocess.check_output(["sizes.exe"]) split_result = result.split() - if str(split_result[0].strip()) != "SIZES": - raise ValueError("First line is not SIZES") - - subs = {"FOMP_SCHED_KIND" : str(split_result[1].strip()), - "FOMP_LOCK_KIND" : str(split_result[2].strip()), - "FOMP_NEST_LOCK_KIND" : str(split_result[3].strip()), - "FOMP_SCHED_STATIC" : str(split_result[4].strip()), - "FOMP_SCHED_DYNAMIC" : str(split_result[5].strip()), - "FOMP_SCHED_GUIDED" : str(split_result[6].strip()), - "FOMP_SCHED_AUTO" : str(split_result[7].strip()) - } + if sys.version_info >= (3, ): + if split_result[0].strip().decode() != "SIZES": + raise ValueError("First line is not SIZES") + + subs = {"FOMP_SCHED_KIND" : split_result[1].strip().decode(), + "FOMP_LOCK_KIND" : split_result[2].strip().decode(), + "FOMP_NEST_LOCK_KIND" : split_result[3].strip().decode(), + "FOMP_SCHED_STATIC" : split_result[4].strip().decode(), + "FOMP_SCHED_DYNAMIC" : split_result[5].strip().decode(), + "FOMP_SCHED_GUIDED" : split_result[6].strip().decode(), + "FOMP_SCHED_AUTO" : split_result[7].strip().decode() + } + else: + if split_result[0].strip() != "SIZES": + raise ValueError("First line is not SIZES") + + subs = {"FOMP_SCHED_KIND" : split_result[1].strip(), + "FOMP_LOCK_KIND" : split_result[2].strip(), + "FOMP_NEST_LOCK_KIND" : split_result[3].strip(), + "FOMP_SCHED_STATIC" : split_result[4].strip(), + "FOMP_SCHED_DYNAMIC" : split_result[5].strip(), + "FOMP_SCHED_GUIDED" : split_result[6].strip(), + "FOMP_SCHED_AUTO" : split_result[7].strip() + } ompgen_temp_path = os.path.join("..", "ompgen.F90.template")