mirror of
https://github.com/RPCSX/xed.git
synced 2026-01-31 01:05:17 +01:00
convert scripts dir to python2or3
Change-Id: I6188243b812050a763efed257797f9c3758706a2 (cherry picked from commit e82817687db19d4dccb10e12f95072e87d3d70e8)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
# -*- python -*-
|
||||
#BEGIN_LEGAL
|
||||
#
|
||||
#Copyright (c) 2016 Intel Corporation
|
||||
#Copyright (c) 2017 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -17,8 +17,10 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
#END_LEGAL
|
||||
|
||||
import sys, os, re
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
from stat import *
|
||||
|
||||
def get_mode(fn):
|
||||
@@ -144,13 +146,13 @@ def apply_header_to_data_file(header, file):
|
||||
####################################################################
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 4:
|
||||
print "Usage " + sys.argv[0] + " [-s|-t] legal-header file-name [file-name...]\n"
|
||||
print("Usage " + sys.argv[0] + " [-s|-t] legal-header file-name [file-name...]\n")
|
||||
sys.exit(1)
|
||||
|
||||
type = sys.argv[1]
|
||||
header_file = sys.argv[2]
|
||||
if not os.path.exists(header_file):
|
||||
print "Could not find header file: [%s]\n" % (header_file)
|
||||
print("Could not find header file: [%s]\n" % (header_file))
|
||||
sys.exit(1)
|
||||
|
||||
files_to_tag = sys.argv[3:]
|
||||
@@ -169,5 +171,5 @@ if __name__ == '__main__':
|
||||
if re.search(".svn",file) == None and re.search(".new$",file) == None:
|
||||
apply_header_to_data_file(header, file.strip())
|
||||
else:
|
||||
print "2nd argument must be -s or -t\n"
|
||||
print("2nd argument must be -s or -t\n")
|
||||
sys.exit(1)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- python -*-
|
||||
#BEGIN_LEGAL
|
||||
#
|
||||
#Copyright (c) 2016 Intel Corporation
|
||||
#Copyright (c) 2017 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
#END_LEGAL
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
@@ -118,7 +118,7 @@ def print_table(data):
|
||||
python27 = mbuild.check_python_version(2,7)
|
||||
fmt_str27 = "{0:10s} {1:10,d} Bytes {2:5.2f} MB {3:10.2f}%"
|
||||
fmt_str = "%10s %10d Bytes %5.2f MB %10.2f%%"
|
||||
keys = data.keys()
|
||||
keys = list(data.keys())
|
||||
keys.sort()
|
||||
|
||||
total = 0
|
||||
@@ -132,15 +132,15 @@ def print_table(data):
|
||||
pct = 0
|
||||
mb = data[k]/1024.0/1024.0
|
||||
if python27:
|
||||
print fmt_str27.format(k,data[k],mb,pct)
|
||||
print(fmt_str27.format(k,data[k],mb,pct))
|
||||
else:
|
||||
print fmt_str % (k,data[k],mb,pct)
|
||||
print(fmt_str % (k,data[k],mb,pct))
|
||||
|
||||
mb = total/1024.0/1024.0
|
||||
if python27:
|
||||
print fmt_str27.format('total', total, mb, 100)
|
||||
print(fmt_str27.format('total', total, mb, 100))
|
||||
else:
|
||||
print fmt_str % ('total', total, mb, 100)
|
||||
print(fmt_str % ('total', total, mb, 100))
|
||||
|
||||
|
||||
def _find_mode(fn,die_on_errors):
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- python -*-
|
||||
#BEGIN_LEGAL
|
||||
#
|
||||
#Copyright (c) 2016 Intel Corporation
|
||||
#Copyright (c) 2017 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
#END_LEGAL
|
||||
|
||||
from __future__ import print_function
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
@@ -36,18 +36,16 @@ def _grab_ldd_libraries(lines):
|
||||
files.append(t[-2])
|
||||
elif pieces == 4:
|
||||
if re.search('not found',line):
|
||||
print "\n\nWARNING: SKIPPING MISSING LIBRARY: [%s]\n\n" % \
|
||||
(t[0])
|
||||
print("\n\nWARNING: SKIPPING MISSING LIBRARY: [{}]\n\n".format(t[0]))
|
||||
else:
|
||||
files.append(t[-2])
|
||||
elif pieces == 3 and t[-2] == '=>':
|
||||
# missing library
|
||||
print "\n\nWARNING: SKIPPING MISSING LIBRARY: [%s]\n\n" % \
|
||||
(line.strip())
|
||||
print ("\n\nWARNING: SKIPPING MISSING LIBRARY: [{}]\n\n".format(line.strip()))
|
||||
else:
|
||||
print "Unrecognized ldd line: [%s]" % line.strip()
|
||||
print("Unrecognized ldd line: [{}]".format(line.strip()))
|
||||
okay = False
|
||||
files = map(os.path.abspath,files)
|
||||
files = [os.path.abspath(x) for x in files]
|
||||
return (okay, files)
|
||||
|
||||
def _file_to_avoid(env,x):
|
||||
@@ -92,7 +90,7 @@ def copy_system_libraries(env, kitdir, files, extra_ld_library_paths=[]):
|
||||
osenv=osenv)
|
||||
for line in lines:
|
||||
line = line.rstrip()
|
||||
print "\t%s"%(line)
|
||||
print("\t{}".format(line))
|
||||
if retval != 0: # error handling
|
||||
if len(lines) >= 1:
|
||||
if lines[0].find("not a dynamic executable") != -1:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# -*- python -*-
|
||||
#BEGIN_LEGAL
|
||||
#
|
||||
#Copyright (c) 2016 Intel Corporation
|
||||
#Copyright (c) 2017 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@
|
||||
#
|
||||
#END_LEGAL
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import sys
|
||||
|
||||
@@ -32,7 +33,7 @@ def find_dir(d,required=True):
|
||||
idir = os.path.dirname(idir)
|
||||
if not os.path.exists(mfile):
|
||||
if required:
|
||||
print "Could not find %s file, looking upwards"% (mfile)
|
||||
print("Could not find {} file, looking upwards".format(mfile))
|
||||
sys.exit(1)
|
||||
return None
|
||||
return mfile
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#-*- python -*-
|
||||
#BEGIN_LEGAL
|
||||
#
|
||||
#Copyright (c) 2016 Intel Corporation
|
||||
#Copyright (c) 2017 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,7 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
#END_LEGAL
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
@@ -50,7 +50,7 @@ def standard_deviation(cpd):
|
||||
|
||||
|
||||
def work(args):
|
||||
print "Testing performance..."
|
||||
print("Testing performance...")
|
||||
|
||||
if not os.path.exists(args.input):
|
||||
mbuild.warn("Performance test input binary not found: {}".format(args.input))
|
||||
@@ -62,11 +62,11 @@ def work(args):
|
||||
s = args.xed + ' -v 0 -i ' + args.input
|
||||
cpd = []
|
||||
|
||||
print "Skipping {} samples...".format(args.skip)
|
||||
print("Skipping {} samples...".format(args.skip))
|
||||
for sample in range(0,args.skip):
|
||||
(status, stdout, stderr) = mbuild.run_command(s)
|
||||
|
||||
print "Running {} tests...".format(args.samples)
|
||||
print("Running {} tests...".format(args.samples))
|
||||
for sample in range(0,args.samples):
|
||||
(status, stdout, stderr) = mbuild.run_command(s)
|
||||
found=False
|
||||
@@ -77,9 +77,9 @@ def work(args):
|
||||
cpd_one = float(chunks[-1])
|
||||
found = True
|
||||
if status and stdout:
|
||||
print "Error messages from sample {0:d}:".format(sample)
|
||||
print("Error messages from sample {0:d}:".format(sample))
|
||||
for line in stdout:
|
||||
print " ",line,
|
||||
print(" ",line, end=' ')
|
||||
if found:
|
||||
cpd.append(cpd_one)
|
||||
|
||||
@@ -90,29 +90,29 @@ def work(args):
|
||||
cpd_min = min(cpd)
|
||||
cpd_max = max(cpd)
|
||||
cpd_avg = sum(cpd)/len(cpd)
|
||||
print textwrap.fill("Samples: " +
|
||||
", ".join(map(lambda x: "{0:6.2f}".format(x),cpd)),
|
||||
subsequent_indent = " ")
|
||||
print(textwrap.fill("Samples: " +
|
||||
", ".join(["{0:6.2f}".format(x) for x in cpd]),
|
||||
subsequent_indent = " "))
|
||||
|
||||
print "Minimum: {0:6.2f}".format(cpd_min)
|
||||
print "Average: {0:6.2f}".format(cpd_avg)
|
||||
print "Maximum: {0:6.2f}".format(cpd_max)
|
||||
print "Range : {0:6.2f}".format(cpd_max-cpd_min)
|
||||
print "Stddev : {0:6.2f}".format(standard_deviation(cpd))
|
||||
print("Minimum: {0:6.2f}".format(cpd_min))
|
||||
print("Average: {0:6.2f}".format(cpd_avg))
|
||||
print("Maximum: {0:6.2f}".format(cpd_max))
|
||||
print("Range : {0:6.2f}".format(cpd_max-cpd_min))
|
||||
print("Stddev : {0:6.2f}".format(standard_deviation(cpd)))
|
||||
|
||||
|
||||
if cpd_avg > expected:
|
||||
s = ["PERFORMANCE DEGREDATION: "]
|
||||
s.append("Observed {0:.2f} vs Expected {1:.2f}".format(
|
||||
cpd_avg, expected))
|
||||
print "".join(s)
|
||||
print("".join(s))
|
||||
return 1 # error
|
||||
print "Success. Average less than {0:.2f}".format(expected)
|
||||
print("Success. Average less than {0:.2f}".format(expected))
|
||||
|
||||
if args.graph:
|
||||
graph_it(cpd)
|
||||
return 0 # success
|
||||
print "MISSING SAMPLES"
|
||||
print("MISSING SAMPLES")
|
||||
return 2
|
||||
|
||||
def setup(defaults):
|
||||
|
||||
Reference in New Issue
Block a user