From d27443deb5f7ea0fd6714adfa831027f4c207094 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Fri, 6 Sep 2019 10:38:45 +0100 Subject: [PATCH] workloads/rt_app: Update to use python3 Update the workload generation script to be python3 compatible and invoke with python3. --- wa/workloads/rt_app/__init__.py | 6 +++--- wa/workloads/rt_app/workgen | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/wa/workloads/rt_app/__init__.py b/wa/workloads/rt_app/__init__.py index 00aadef9..9b2a0361 100644 --- a/wa/workloads/rt_app/__init__.py +++ b/wa/workloads/rt_app/__init__.py @@ -260,9 +260,9 @@ class RtApp(Workload): # use workgen dry run option to generate a use case # file with proper JSON grammar on host first try: - check_output('python {} -d -o {} {}'.format(self.workgen_script, - output_file, - user_file), + check_output('python3 {} -d -o {} {}'.format(self.workgen_script, + output_file, + user_file), shell=True) except CalledProcessError as e: message = 'Could not generate config using workgen, got "{}"' diff --git a/wa/workloads/rt_app/workgen b/wa/workloads/rt_app/workgen index c85d6b0a..55aa3869 100755 --- a/wa/workloads/rt_app/workgen +++ b/wa/workloads/rt_app/workgen @@ -9,12 +9,12 @@ import re def check_unikid_json(infile, outfile, verbose=0): if not os.path.exists(infile): - print "WARN: %s does not exist", infile + print("WARN: %s does not exist", infile) try: fi = open(infile, "r") except IOError: - print "WARN: Unable to open %s", infile + print("WARN: Unable to open %s", infile) sys.exit(2) lines = fi.readlines() @@ -23,7 +23,7 @@ def check_unikid_json(infile, outfile, verbose=0): try: fo = open(outfile, "w+") except IOError: - print "WARN: Unable to open %s", f + print("WARN: Unable to open %s", f) sys.exit(2) curid = 1 @@ -58,7 +58,7 @@ def check_unikid_json(infile, outfile, verbose=0): newkey_id = key_id + str(curid) if verbose: - print "level ", refcount, " : key ", key_id, " changed into ", newkey_id + print("level ", refcount, " : key ", key_id, " changed into ", newkey_id) myline = myline.replace(key_id, newkey_id, 1) key_id = newkey_id @@ -72,12 +72,12 @@ def check_unikid_json(infile, outfile, verbose=0): def check_suspend_json(infile, outfile, verbose=0): if not os.path.exists(infile): - print "WARN: %s does not exist", infile + print("WARN: %s does not exist", infile) try: fi = open(infile, "r") except IOError: - print "WARN: Unable to open %s", infile + print("WARN: Unable to open %s", infile) sys.exit(2) lines = fi.readlines() @@ -86,7 +86,7 @@ def check_suspend_json(infile, outfile, verbose=0): try: fo = open(outfile, "w+") except IOError: - print "WARN: Unable to open %s", f + print("WARN: Unable to open %s", f) sys.exit(2) @@ -123,7 +123,7 @@ def check_suspend_json(infile, outfile, verbose=0): exception == 1: if verbose: - print "value ", curid, " added to suspend key" + print("value ", curid, " added to suspend key") if "," in myline: myline = myline.replace(",", " : " + "\"" + curid + "\",", 1) @@ -142,7 +142,7 @@ def remove_trailing_commas(outfile): try: f = open(outfile, 'r+') except IOError: - print "WARN: Unable to open %s", f + print("WARN: Unable to open %s", f) sys.exit(2) lines = f.read() @@ -180,7 +180,7 @@ def remove_all_comments(outfile): try: f = open(outfile, 'r+') except IOError: - print "WARN: Unable to open %s", f + print("WARN: Unable to open %s", f) sys.exit(2) lines = f.read() @@ -210,7 +210,7 @@ if __name__ == '__main__': try: opts, args = getopt.getopt(sys.argv[1:], "o:avd") except getopt.GetoptError as err: - print str(err) # will print something like "option -a not recognized" + print(str(err)) # will print something like "option -a not recognized" sys.exit(2) for o, a in opts: