From e0e6c72e94c754b76b1cdd4cbc44a15762e04dee Mon Sep 17 00:00:00 2001 From: "Marty E. Plummer" Date: Fri, 10 May 2019 00:43:56 -0500 Subject: treewide: use print function instead of statement This enables better compat between python2.7 and python3.x Without this change, building with python3.x (python3.5 tested) as /usr/bin/python will result in the following error: File: "sbe/src/build/security/securityRegListGen.py", line 64 -v, --verbose enable verbose traces" ^ SyntaxError: Missing parentheses in call to 'print' Signed-off-by: Marty E. Plummer Change-Id: Id617f54096fca5cc5fcd829767595a85350e343d Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/89618 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Reviewed-by: RAJA DAS --- src/tools/debug/sbe-debug.py | 135 ++++++++++++------------ src/tools/debug/simics-debug-framework.py | 49 ++++----- src/tools/utils/CommitSbeImageToCMVC.py | 167 +++++++++++++++--------------- src/tools/utils/cmvcRelease.py | 25 ++--- src/tools/utils/sbeCmvcUtility.py | 95 ++++++++--------- src/tools/utils/sbePatchUtility.py | 11 +- src/tools/utils/sbePrime.py | 105 +++++++++---------- 7 files changed, 297 insertions(+), 290 deletions(-) (limited to 'src/tools') diff --git a/src/tools/debug/sbe-debug.py b/src/tools/debug/sbe-debug.py index 5d53b408..fad7fd4e 100755 --- a/src/tools/debug/sbe-debug.py +++ b/src/tools/debug/sbe-debug.py @@ -6,7 +6,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2016,2019 +# Contributors Listed Below - COPYRIGHT 2016,2020 # [+] International Business Machines Corp. # # @@ -23,6 +23,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import os import subprocess import re @@ -63,7 +64,7 @@ def getFilePath(filename): retPath = os.path.join(dir, filename) if(os.path.exists(retPath)): return os.path.abspath(retPath) - print "ERROR: file " + filename +" not found" + print("ERROR: file " + filename +" not found") return 1 def getTraceFilePath(): @@ -84,7 +85,7 @@ def fillSymTable(): if( len( words ) == 4 ): syms[words[3]] = [words[0], words[1]] except: - print "Symbol file not found, limited commands avaliable" + print("Symbol file not found, limited commands avaliable") def getSymbolInfo( symbol ): symAddr = '' @@ -99,8 +100,8 @@ def getSymbolInfo( symbol ): else: baseAddr = 0xfffe8000 - print "\n symAddress :", symAddr - print "\n baseAddress :", baseAddr + print("\n symAddress :", symAddr) + print("\n baseAddress :", baseAddr) offset = int(symAddr, base = 16) - baseAddr; return (hex(offset), length) @@ -133,13 +134,13 @@ def getSymbolVal(symbol, hexdump=False): if hexdump: invokeOsCmd( "hexdump -C "+ output_path +"DumpPIBMEM" ) else: - print "symbol not found" + print("symbol not found") def invokeOsCmd(cmd): - print "Running command [" + cmd + "]" + print("Running command [" + cmd + "]") rc = os.system( cmd ) if ( rc ): - print "ERROR running command: %d " % ( rc ) + print("ERROR running command: %d " % ( rc )) return 1 ''' @@ -179,13 +180,13 @@ def forcedCollectTrace(): trace_pattern = [0, 2, 0, 0] + [ord(a) for a in image_str] + [0] data_read = [0] * len(trace_pattern) trace_index = 0 - #print trace_pattern + #print(trace_pattern) with open(output_path+"DumpPIBMEM", "r") as f: byte = 'x' while byte != "": byte = f.read(1) data_read = data_read[1:]+[ord(byte)] - #print [chr(a) for a in data_read] + #print([chr(a) for a in data_read]) if data_read == trace_pattern: trace_index -= len(trace_pattern)-1 break @@ -226,8 +227,8 @@ def collectStackUsage(): # Dump stack memory to binary file invokeOsCmd( "cat "+ output_path +"DumpPIBMEM >"+ output_path + thread ) - print "==================================Stack usage===================================" - print "Thread".ljust(40)+"Least Available[bytes]".ljust(30)+"Max usage[%]" + print("==================================Stack usage===================================") + print("Thread".ljust(40)+"Least Available[bytes]".ljust(30)+"Max usage[%]") for thread in threads: with open(output_path+thread, "rb") as f: word = struct.unpack('I', f.read(4))[0] @@ -241,7 +242,7 @@ def collectStackUsage(): break else: break - print str("["+thread+"]").ljust(40) + str(leastAvailable).ljust(30) + str("%.2f" % (100 * (1 - (leastAvailable/float(int("0x"+syms[thread][1], 16)))))) + print(str("["+thread+"]").ljust(40) + str(leastAvailable).ljust(30) + str("%.2f" % (100 * (1 - (leastAvailable/float(int("0x"+syms[thread][1], 16))))))) def getSbeCommit(): getSymbolVal( 'SBEGlobalsSingleton.*fwCommitId' ) @@ -249,7 +250,7 @@ def getSbeCommit(): with open(output_path+"DumpPIBMEM", "rb") as f: # Big Endian word word = struct.unpack('>I', f.read(4))[0] - print "SBE commit:", hex(word) + print("SBE commit:", hex(word)) def ppeStateFfdc(): # Keep this structure in sync with src/sbefw/core/sbeirqregistersave.H @@ -274,25 +275,25 @@ def ppeStateFfdc(): data = f.read() ctypes.memmove(ctypes.addressof(ppestateffdc), data, ctypes.sizeof(ppestateffdc)) - print ''' + print(''' --------------------------------------------------------------------------------- Please verify sbe_DD2.syms is valid for this dump, before depending on the values ----------------------------------------------------------------------------------''' +---------------------------------------------------------------------------------''') if ppestateffdc.validbyte == 0x1 and ppestateffdc.magicbyte == 0xA5: - print "ppestateffdc.version 0x%04X" % ppestateffdc.version - print "ppestateffdc.magicbyte 0x%02X" % ppestateffdc.magicbyte - print "ppestateffdc.validbyte 0x%02X" % ppestateffdc.validbyte - print "ppestateffdc.register_SRR0 0x%08X" % ppestateffdc.register_SRR0 - print "ppestateffdc.register_SRR1 0x%08X" % ppestateffdc.register_SRR0 - print "ppestateffdc.register_ISR 0x%08X" % ppestateffdc.register_ISR - print "ppestateffdc.register_FI2C_CONFIG_LOWER_32BITS 0x%08X" % ppestateffdc.register_FI2C_CONFIG_LOWER_32BITS - print "ppestateffdc.register_FI2C_CONFIG_UPPER_32BITS 0x%08X" % ppestateffdc.register_FI2C_CONFIG_UPPER_32BITS - print "ppestateffdc.register_FI2C_STAT_LOWER_32BITS 0x%08X" % ppestateffdc.register_FI2C_STAT_LOWER_32BITS - print "ppestateffdc.register_FI2C_STAT_UPPER_32BITS 0x%08X" % ppestateffdc.register_FI2C_STAT_UPPER_32BITS - print "ppestateffdc.register_LR 0x%08X" % ppestateffdc.register_LR + print("ppestateffdc.version 0x%04X" % ppestateffdc.version) + print("ppestateffdc.magicbyte 0x%02X" % ppestateffdc.magicbyte) + print("ppestateffdc.validbyte 0x%02X" % ppestateffdc.validbyte) + print("ppestateffdc.register_SRR0 0x%08X" % ppestateffdc.register_SRR0) + print("ppestateffdc.register_SRR1 0x%08X" % ppestateffdc.register_SRR0) + print("ppestateffdc.register_ISR 0x%08X" % ppestateffdc.register_ISR) + print("ppestateffdc.register_FI2C_CONFIG_LOWER_32BITS 0x%08X" % ppestateffdc.register_FI2C_CONFIG_LOWER_32BITS) + print("ppestateffdc.register_FI2C_CONFIG_UPPER_32BITS 0x%08X" % ppestateffdc.register_FI2C_CONFIG_UPPER_32BITS) + print("ppestateffdc.register_FI2C_STAT_LOWER_32BITS 0x%08X" % ppestateffdc.register_FI2C_STAT_LOWER_32BITS) + print("ppestateffdc.register_FI2C_STAT_UPPER_32BITS 0x%08X" % ppestateffdc.register_FI2C_STAT_UPPER_32BITS) + print("ppestateffdc.register_LR 0x%08X" % ppestateffdc.register_LR) else: - print "Register ffdc is not valid, probably SBE has not hit any internal halt condition" - print '''---------------------------------------------------------------------------------''' + print("Register ffdc is not valid, probably SBE has not hit any internal halt condition") + print('''---------------------------------------------------------------------------------''') def ppeState(): if(target == 'FILE'): @@ -361,12 +362,12 @@ def ppeState(): 30 : ["R30", False], 31 : ["R31", False] } - print "File path: ", file_path + print("File path: ", file_path) fileHandle = open(file_path) l_cnt = 0 - print '********************************************************************' - print 'Reg'.ljust(15),'Reg Value'.ljust(20) - print '--------------------------------------------------------------------' + print('********************************************************************') + print('Reg'.ljust(15),'Reg Value'.ljust(20)) + print('--------------------------------------------------------------------') while(l_cnt < os.path.getsize(file_path)): regNum = int(binascii.hexlify(fileHandle.read(2)), 16) str1 = '' @@ -381,10 +382,10 @@ def ppeState(): except: str1 = hex(regNum) str3 = binascii.hexlify(fileHandle.read(4)) - print str(str1).ljust(15),str(str3).ljust(20) + print(str(str1).ljust(15),str(str3).ljust(20)) l_cnt = l_cnt + 6; - print '********************************************************************' + print('********************************************************************') fileHandle.close() else: invokeOsCmd(getFilePath("p9_ppe_state_wrap.exe")+" -verbose -sbe -snapshot"+ @@ -392,19 +393,19 @@ def ppeState(): def sbeLocalRegister(): if(target == 'FILE'): - print "File path: ", file_path + print("File path: ", file_path) fileHandle = open(file_path) l_cnt = 0 - print '********************************************************************' - print 'Reg Number Reg Value Reg String' + print('********************************************************************') + print('Reg Number Reg Value Reg String') while(l_cnt < os.path.getsize(file_path)): str1 = binascii.hexlify(fileHandle.read(2)) str2 = fileHandle.read(32) str3 = binascii.hexlify(fileHandle.read(8)) - print str(str1).ljust(11),str(str3).ljust(20),str2.ljust(40) + print(str(str1).ljust(11),str(str3).ljust(20),str2.ljust(40)) l_cnt = l_cnt + 42; - print '********************************************************************' + print('********************************************************************') fileHandle.close() else: invokeOsCmd(getFilePath("p9_sbe_localreg_dump_wrap.exe")+" -verbose -halt"+ @@ -412,19 +413,19 @@ def sbeLocalRegister(): def sbeState(): if(target == 'FILE'): - print "File path: ", file_path + print("File path: ", file_path) fileHandle = open(file_path) l_cnt = 0 - print '********************************************************************' - print 'Reg Number Reg Value Reg String' + print('********************************************************************') + print('Reg Number Reg Value Reg String') while(l_cnt < os.path.getsize(file_path)): str1 = binascii.hexlify(fileHandle.read(4)) str2 = fileHandle.read(32) str3 = binascii.hexlify(fileHandle.read(8)) - print str(str1).ljust(11),str(str3).ljust(20),str2.ljust(40) + print(str(str1).ljust(11),str(str3).ljust(20),str2.ljust(40)) l_cnt = l_cnt + 44; - print '********************************************************************' + print('********************************************************************') fileHandle.close() else: invokeOsCmd(getFilePath("p9_pibms_reg_dump_wrap.exe")+" -verbose" +\ @@ -432,17 +433,17 @@ def sbeState(): def sbeStatus(): if(target == 'FILE'): - print "Error - not supported for FILE Target" + print("Error - not supported for FILE Target") else: cmd = ("getcfam pu 2809" +\ " -n" + str(node) + " -p" + str(proc)) - print "cmd:", cmd + print("cmd:", cmd) output = os.popen(cmd).read() output = output.split() expected_out = 'k0:n%1d:s0:p%02d'%(node,proc) if (expected_out not in output): - print "Error while getting the status register" - print ' '.join(output) + print("Error while getting the status register") + print(' '.join(output)) else: parsevalue(bin(int(output[output.index(expected_out)+1], 16))) @@ -456,30 +457,30 @@ def parsevalue(iValue): tempVal = iValue[2:3] tempVal = 'True' if tempVal == '1' else 'False' - print "SBE Booted : %s" %(tempVal) + print("SBE Booted : %s" %(tempVal)) tempVal = iValue[3:4] tempVal = 'True' if tempVal == '1' else 'False' - print "Async FFDC : %s" %(tempVal) + print("Async FFDC : %s" %(tempVal)) tempVal = iValue[4:6] - print "Reserver Bit [2:3] : %s" %(tempVal) + print("Reserver Bit [2:3] : %s" %(tempVal)) tempVal = iValue[6:10] - print "SBE Previous State : %s (%s)" %(sbeStates[tempVal], tempVal) + print("SBE Previous State : %s (%s)" %(sbeStates[tempVal], tempVal)) tempVal = iValue[10:14] - print "SBE Current State : %s (%s)" %(sbeStates[tempVal], tempVal) + print("SBE Current State : %s (%s)" %(sbeStates[tempVal], tempVal)) tempVal = iValue[14:22] - print "Istep Major : %s" %(int(tempVal, 2)) + print("Istep Major : %s" %(int(tempVal, 2))) tempVal = iValue[22:28] - print "Istep Minor : %s" %(int(tempVal, 2)) + print("Istep Minor : %s" %(int(tempVal, 2))) tempVal = iValue[28:34] - print "Reserved Bit [26:31] : %s" %(tempVal) + print("Reserved Bit [26:31] : %s" %(tempVal)) ''' @@ -516,7 +517,7 @@ def main( argv ): try: opts, args = getopt.getopt(sys.argv[1:], "l:t:n:p:d:s:f:o:h", ['level=', 'target=', 'node=', 'proc=', 'ddlevel=', 'symbol=', 'file_path=', 'output_path=','help']) except getopt.GetoptError as err: - print str(err) + print(str(err)) usage() exit(1) @@ -534,45 +535,45 @@ def main( argv ): if arg in LEVELS_ARRAY: level = arg else: - print "level should be one of " + str(LEVELS_ARRAY) + print("level should be one of " + str(LEVELS_ARRAY)) exit(1) elif opt in ('-t', '--target'): if arg in ('AWAN', 'HW', 'FILE'): target = arg else: - print "target should be one of {AWAN,HW,FILE}" + print("target should be one of {AWAN,HW,FILE}") exit(1) elif opt in ('-n', '--node'): try: node = int(arg) except: - print "node should be an integer number" + print("node should be an integer number") exit(1) elif opt in ('-p', '--proc'): try: proc = int(arg) except: - print "proc should be an integer number" + print("proc should be an integer number") exit(1) elif opt in ('-d', '--ddlevel'): if arg in ('DD1', 'DD2', 'AXONE'): ddsuffix = arg else: - print "target should be one of {DD1, DD2, AXONE}" + print("target should be one of {DD1, DD2, AXONE}") exit(1) elif opt in ('-f', '--file_path'): try: file_path = arg assert os.path.exists(arg), "Did not find the file at,"+str(arg) except: - print "file_path should a string path" + print("file_path should a string path") exit(1) elif opt in ('-o', '--output_path'): try: output_path = arg+"/" assert os.path.exists(arg) except: - print "output_path should a string path" + print("output_path should a string path") exit(1) elif opt in ('-s', '--symbol'): symbol = arg @@ -583,7 +584,7 @@ def main( argv ): # Example output: 'CNFG FILE GLOBAL_DEBUG: 8.VI.B\n\tk0 \nUSE_SBE_FIFO = off\n/afs/awd.austin.ibm.com/projects/eng/tools/cronus/p9/exe/dev/p9sim_dev_x86_64.exe getconfig USE_SBE_FIFO \n' regEx = re.search('USE_SBE_FIFO.*=(.*)', cmdFifoLastState) if (regEx == None): - print "ERROR in getting USE_SBE_FIFO config" + print("ERROR in getting USE_SBE_FIFO config") return 1 cmdFifoLastState = regEx.group(1).split()[0] # On cronus, disabe FIFO mode @@ -596,7 +597,7 @@ def main( argv ): fillSymTable() if ( level == 'all' ): - print "Parsing everything" + print("Parsing everything") collectTrace() collectAttr() sbeStatus() diff --git a/src/tools/debug/simics-debug-framework.py b/src/tools/debug/simics-debug-framework.py index 359df50d..969cb32f 100755 --- a/src/tools/debug/simics-debug-framework.py +++ b/src/tools/debug/simics-debug-framework.py @@ -5,7 +5,7 @@ # # OpenPOWER sbe Project # -# Contributors Listed Below - COPYRIGHT 2016,2019 +# Contributors Listed Below - COPYRIGHT 2016,2020 # [+] International Business Machines Corp. # # @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import os import os.path import subprocess @@ -44,7 +45,7 @@ if getMachineName() == "axone": SBE_TOOLS_PATH = simenv.sbe_scripts_path else: SBE_TOOLS_PATH = os.environ['SBE_TOOLS_PATH'] -print "SBE_TOOLS_PATH = " + SBE_TOOLS_PATH +print("SBE_TOOLS_PATH = " + SBE_TOOLS_PATH) testIstepAuto = imp.load_source("testIstepAuto", SBE_TOOLS_PATH + "/testIstepAuto.py") sbeDebug = imp.load_source("sbeDebug", SBE_TOOLS_PATH + "/sbe-debug.py") @@ -65,7 +66,7 @@ def check_sbe_tools_path (): cmd1 = "pipe \"echo $cec_type\" \"cat > temp1.map\"" ( rc, out ) = quiet_run_command( cmd1, output_modes.regular ) if ( rc ): - print "simics ERROR running %s: %d "%( cmd1, rc ) + print ("simics ERROR running %s: %d "%( cmd1, rc )) with open('temp1.map', 'r') as f: map = f.read().strip() if(map == "p9_fleetwood"): @@ -85,10 +86,10 @@ def get_dd_level(procNr = 0, nodeNr = 0): else: cmd = "pipe \"p9Proc"+str(procNr)+".sbe.mibo_space.map\" \"cat > temp.map\"" - print "simics running %s: "%( cmd) + print ("simics running %s: "%( cmd)) ( rc, out ) = quiet_run_command( cmd, output_modes.regular ) if ( rc ): - print "simics ERROR running %s: %d "%( cmd, rc ) + print ("simics ERROR running %s: %d "%( cmd, rc )) ddlevel = 'DD1' with open('temp.map', 'r') as f: map = f.read() @@ -103,7 +104,7 @@ def get_dd_level(procNr = 0, nodeNr = 0): ddlevel = "DD1" if map[map.index('p9Proc'+str(procNr)+'.sbe.fi2c_bo:fi2cfsm')-1] == '0xff800000': ddlevel = "DD2" - print "running image - ["+ddlevel+"]" + print ("running image - ["+ddlevel+"]") return ddlevel def register_sbe_debug_framework_tools(): @@ -147,12 +148,12 @@ def register_sbe_debug_framework_tools(): short = "Runs the debug framework for register ffdc ", doc = "") - print "SBE Debug Framework: Registered tool:", "sbe-istep" - print "SBE Debug Framework: Registered tool:", "sbe-trace" - print "SBE Debug Framework: Registered tool:", "sbe-stack" - print "SBE Debug Framework: Registered tool:", "sbe-ddlevel" - print "SBE Debug Framework: Registered tool:", "sbe-attrdump" - print "SBE Debug Framework: Registered tool:", "sbe-regffdc" + print("SBE Debug Framework: Registered tool:", "sbe-istep") + print("SBE Debug Framework: Registered tool:", "sbe-trace") + print("SBE Debug Framework: Registered tool:", "sbe-stack") + print("SBE Debug Framework: Registered tool:", "sbe-ddlevel") + print("SBE Debug Framework: Registered tool:", "sbe-attrdump") + print("SBE Debug Framework: Registered tool:", "sbe-regffdc") def fillSymTable(): @@ -175,7 +176,7 @@ def collectStackUsage ( procNr, nodeNr=0 ): 'sbeCommandReceiver_stack', 'sbe_Kernel_NCInt_stack', 'sbeAsyncCommandProcessor_stack') - print "==================================Stack usage===================================" + print("==================================Stack usage===================================") # Dump stack memory to binary files for thread in threads: if g_isFleetwood: @@ -186,12 +187,12 @@ def collectStackUsage ( procNr, nodeNr=0 ): cmd = "pipe \"backplane0.proc" + `procNr` + ".pib_cmp.sbe_mibo.x 0x" + syms[thread][0] + " 0x"+syms[thread][1]+"\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> "+thread+"\"" else: cmd = "pipe \"p9Proc" + `procNr` + ".sbe.mibo_space.x 0x" + syms[thread][0] + " 0x"+syms[thread][1]+"\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> "+thread+"\"" - print "simics running %s: "%( cmd) + print ("simics running %s: "%( cmd)) ( rc, out ) = quiet_run_command( cmd, output_modes.regular ) if ( rc ): - print "simics ERROR running %s: %d "%( cmd, rc ) + print("simics ERROR running %s: %d "%( cmd, rc )) - print "Thread".ljust(40)+"Least Available[bytes]".ljust(30)+"Max usage[%]" + print("Thread".ljust(40)+"Least Available[bytes]".ljust(30)+"Max usage[%]") for thread in threads: with open(thread, "rb") as f: word = struct.unpack('I', f.read(4))[0] @@ -202,7 +203,7 @@ def collectStackUsage ( procNr, nodeNr=0 ): word = struct.unpack('I', f.read(4))[0] else: break - print str("["+thread+"]").ljust(40) + str(leastAvailable).ljust(30) + str("%.2f" % (100 * (1 - (leastAvailable/float(int("0x"+syms[thread][1], 16)))))) + print(str("["+thread+"]").ljust(40) + str(leastAvailable).ljust(30) + str("%.2f" % (100 * (1 - (leastAvailable/float(int("0x"+syms[thread][1], 16))))))) def collectAttr( procNr, nodeNr=0 ): global g_isFleetwood @@ -211,10 +212,10 @@ def collectAttr( procNr, nodeNr=0 ): cmd= "pipe \"D"+str(node)+"Proc"+str(procNr)+".sbe.mibo_space.x " + '0xFFFE8000' + " "+hex(96*1024)+"\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> DumpFullPIBMEM\"" else: cmd= "pipe \"p9Proc" + `procNr` + ".sbe.mibo_space.x " + '0xFFFE8000' + " "+hex(96*1024)+"\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> DumpFullPIBMEM\"" - print "simics running %s: "%( cmd) + print("simics running %s: "%( cmd)) ( rc, out ) = quiet_run_command( cmd, output_modes.regular ) if ( rc ): - print "simics ERROR running %s: %d "%( cmd, rc ) + print("simics ERROR running %s: %d "%( cmd, rc )) ddlevel = get_dd_level(procNr, nodeNr) sbeDebug.ddsuffix = ddlevel sbeDebug.target = 'FILE' @@ -232,10 +233,10 @@ def collectRegFfdc( procNr, nodeNr=0 ): cmd = "pipe \"backplane0.proc" + `procNr` + ".pib_cmp.sbe_mibo.x " + '0xFFFE8000' + " "+hex(96*1024)+"\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> DumpFullPIBMEM\"" else: cmd= "pipe \"p9Proc" + `procNr` + ".sbe.mibo_space.x " + '0xFFFE8000' + " "+hex(96*1024)+"\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> DumpFullPIBMEM\"" - print "simics running %s: "%( cmd) + print ("simics running %s: "%( cmd)) ( rc, out ) = quiet_run_command( cmd, output_modes.regular ) if ( rc ): - print "simics ERROR running %s: %d "%( cmd, rc ) + print("simics ERROR running %s: %d "%( cmd, rc )) ddlevel = get_dd_level(procNr, nodeNr) sbeDebug.ddsuffix = ddlevel sbeDebug.target = 'FILE' @@ -266,10 +267,10 @@ def collectTrace ( procNr, nodeNr=0 ): cmd3 = "shell \"fsp-trace -s " + SBE_TOOLS_PATH + "/sbeStringFile_"+get_dd_level(procNr, nodeNr)+" sbetrace.bin >" + fileName + "\"" cmd4 = "shell \"" + "cat " + fileName + "\"" - print "simics running %s: "%( cmd1) + print("simics running %s: "%( cmd1)) ( rc, out ) = quiet_run_command( cmd1, output_modes.regular ) if ( rc ): - print "simics ERROR running %s: %d "%( cmd1, rc ) + print("simics ERROR running %s: %d "%( cmd1, rc )) run_command ( cmd2 ) run_command ( cmd3 ) @@ -287,7 +288,7 @@ def sbe_magic_instruction_callback(user_arg, cpu, inst_num): if inst_num == 8000: #MAGIC_SIMICS_CHECK iface = SIM_get_interface(cpu, "int_register") iface.write(iface.get_number("r3"), 1) - print "SBE::isSimicsRunning = true" + print("SBE::isSimicsRunning = true") # Run the registration automatically whenever this script is loaded. register_sbe_debug_framework_tools() diff --git a/src/tools/utils/CommitSbeImageToCMVC.py b/src/tools/utils/CommitSbeImageToCMVC.py index c177e72f..f5394e46 100755 --- a/src/tools/utils/CommitSbeImageToCMVC.py +++ b/src/tools/utils/CommitSbeImageToCMVC.py @@ -41,6 +41,7 @@ #------------------------- # Imports #------------------------- +from __future__ import print_function import getopt import os, sys, glob import shutil @@ -58,37 +59,37 @@ def main(): # Usage tool option #------------------------------------------ def usage(): - print " ---------------------------------------------------------------------------------------------------" - print " :: Command line USAGE options for Uploading FW SBE image to CMVC :: \n" - print " CommitSbeImageToCMVC.py -d -r -p -i " - - print " \n" - print " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" - print " | By default user MUST pass CMVC/Release/Path input. |" - print " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" - print " \n ***** Options Supported *****" - print " \t -d,--defect = Defect CMVC number" - print " \t -f,--feature = Feature CMVC number" - print " \t -r,--release = FW fips release string EX: fips910" - print " \t -p,--path = Absolute path of the SBE repo" - print " \t -i,--input = [ Optional ] List of image or file to upload" - print " \t -b,--bvt = BVT xml file for CI" - print " \t -h,--help = Help" - print " ------------------------------------------------------------------------------------" + print(" ---------------------------------------------------------------------------------------------------") + print(" :: Command line USAGE options for Uploading FW SBE image to CMVC :: \n") + print(" CommitSbeImageToCMVC.py -d -r -p -i ") + + print(" \n") + print(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") + print(" | By default user MUST pass CMVC/Release/Path input. |") + print(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") + print(" \n ***** Options Supported *****") + print(" \t -d,--defect = Defect CMVC number") + print(" \t -f,--feature = Feature CMVC number") + print(" \t -r,--release = FW fips release string EX: fips910") + print(" \t -p,--path = Absolute path of the SBE repo") + print(" \t -i,--input = [ Optional ] List of image or file to upload") + print(" \t -b,--bvt = BVT xml file for CI") + print(" \t -h,--help = Help") + print(" ------------------------------------------------------------------------------------") #------------------------------------------ # Exit from this Main #------------------------------------------ def exit_main(rc): if rc == errorcode.HELP_EXIT: - print " [ HELP DOCUMENTATION ]\n" + print(" [ HELP DOCUMENTATION ]\n") sys.exit(0) if rc: - print "\n [ ERROR - MAIN ] Exiting with error code = ", rc + print("\n [ ERROR - MAIN ] Exiting with error code = ", rc) sys.exit(rc) else: - print "\n SBE Image Upload to CMVC completed [ OK ] " + print("\n SBE Image Upload to CMVC completed [ OK ] ") sys.exit(0) #------------------------------------------ @@ -128,10 +129,10 @@ def main(): #---------------------------------- # Preping the data for Image Upload #---------------------------------- - print " \n" - print " ******************************************************" - print " ****** Stagging PPE image Files Upload to CMVC ******" - print " ******************************************************" + print(" \n") + print(" ******************************************************") + print(" ****** Stagging PPE image Files Upload to CMVC ******") + print(" ******************************************************") #------------------------------------------------------ # Make sure that it has passed atleast one arg with it @@ -144,45 +145,45 @@ def main(): # Check user inputs and display #------------------------------------------------------------- def input_setting(): - print " ---------------------------------------------------------------------------------" - print " [ Display User Inputs ]" - print " ---------------------------------------------------------------------------------" + print(" ---------------------------------------------------------------------------------") + print(" [ Display User Inputs ]") + print(" ---------------------------------------------------------------------------------") # Look elsewhere for the name instead of assigning to it locally. # This is now gloabal var global g_cmvc_num if ( defect_num != "None" ) or ( feature_num != "None" ): if not defect_num == "None": g_cmvc_num = 'D'+defect_num #D1234 - print " [ CMVC Defect ] \t\t#Number\t = %s"%(g_cmvc_num) + print(" [ CMVC Defect ] \t\t#Number\t = %s"%(g_cmvc_num)) else: g_cmvc_num = 'F'+feature_num # F1234 - print " [ CMVC Feature ] \t\t#Number\t = %s"%(g_cmvc_num) + print(" [ CMVC Feature ] \t\t#Number\t = %s"%(g_cmvc_num)) else: - print " [ CMVC Defect/Feature ] Neeed CMVC number. This can't be empty " + print(" [ CMVC Defect/Feature ] Neeed CMVC number. This can't be empty ") exit_main(errorcode.ERROR_EXIT) if not release_name == "None": - print " [ Fips Release Name ] \t#String\t = %s"%(release_name) + print(" [ Fips Release Name ] \t#String\t = %s"%(release_name)) else: - print " [ Fips release ] Neeed fips release string. This can't be empty " + print(" [ Fips release ] Neeed fips release string. This can't be empty ") exit_main(errorcode.ERROR_EXIT) if not path_name == "None": - print " [ Build Repo Path ] \t\t#String\t = %s"%(path_name) + print(" [ Build Repo Path ] \t\t#String\t = %s"%(path_name)) else: - print " [ User Build Repo Path ] \t\t#String\t = %s"%(path_name) + print(" [ User Build Repo Path ] \t\t#String\t = %s"%(path_name)) # Optional, by default looks up predefined files if not file_name == "None": - print " [ Files for Check-in - User List ]" + print(" [ Files for Check-in - User List ]") for files in file_name.split(","): - print " \t\t\t\t#",files + print(" \t\t\t\t#",files) else: - print " [ Files for Check-in - Default List ]" + print(" [ Files for Check-in - Default List ]") for files in errorcode.CMVC_FILE_LIST.split(","): - print " \t\t\t\t# ",files + print(" \t\t\t\t# ",files) - print " ---------------------------------------------------------------------------------" + print(" ---------------------------------------------------------------------------------") #------------------------------------------------------------- # CMVC ENV check @@ -200,17 +201,17 @@ def main(): l_found_cmvc_conf = False for key in os.environ.keys(): if "CMVC" in key: - print "\t %s : %s" % (key,os.environ[key]) + print("\t %s : %s" % (key,os.environ[key])) l_found_cmvc_conf = True if l_found_cmvc_conf == False: - print "\n [ ERROR SETTING ] : The CMVC specific ENV is not set" - print " Please add the following CMVC details in ~/.bashrc" - print " ------------------------------------------------------" - print " export CMVC_FAMILY=aix@@" - print " export CMVC_BECOME=" - print " export CMVC_AUTH_METHOD=PWD" - print " ------------------------------------------------------" + print("\n [ ERROR SETTING ] : The CMVC specific ENV is not set") + print(" Please add the following CMVC details in ~/.bashrc") + print(" ------------------------------------------------------") + print(" export CMVC_FAMILY=aix@@") + print(" export CMVC_BECOME=") + print(" export CMVC_AUTH_METHOD=PWD") + print(" ------------------------------------------------------") return errorcode.ERROR_SETTING return errorcode.SUCCESS_EXIT @@ -231,67 +232,67 @@ def main(): #------------------------------ input_setting() - print "\n [ Checking PPE ENV Pre-req ] " + print("\n [ Checking PPE ENV Pre-req ] ") # Check if User has passed the path, else get it from ENV if path_name == "None": # Get the PPE path l_ppe_path = utilcode.utilppeSbENV("SBEROOT") if l_ppe_path == "None": - print " PPE Repo ENV Setting Path : [ ERROR CODE: %s ] " % l_ppe_path + print(" PPE Repo ENV Setting Path : [ ERROR CODE: %s ] " % l_ppe_path) exit_main(errorcode.ERROR_SETTING) else: - print " PPE Repo path Setting : [ %s ]"% l_ppe_path + print(" PPE Repo path Setting : [ %s ]"% l_ppe_path) path_name = l_ppe_path - print "\n [ Checking CMVC user ENV Pre-req ] " + print("\n [ Checking CMVC user ENV Pre-req ] ") rc_code = UserCmvcENV() if rc_code == errorcode.SUCCESS_EXIT : - print " CMVC Setting : [ OK ] " + print(" CMVC Setting : [ OK ] ") else: - print " CMVC Setting : [ ERORR CODE: %s ]"% rc_code + print(" CMVC Setting : [ ERORR CODE: %s ]"% rc_code) #------------------------------ # 2) Check the CMVC login access #------------------------------ - print "\n [ Checking CMVC user Login Session access ] " + print("\n [ Checking CMVC user Login Session access ] ") rc_cmvc = CheckCmvcAccess() if rc_cmvc == errorcode.ERROR_CMVC_LOGIN: - print " CMVC Login Access : [ ERORR CODE: %s ]"% rc_cmvc - print "\t No cmvc login was found in this session." - print "\t Issue the cmvclog command to establish a login and re-run." - print "\t Command : cmvclog -in " + print(" CMVC Login Access : [ ERORR CODE: %s ]"% rc_cmvc) + print("\t No cmvc login was found in this session.") + print("\t Issue the cmvclog command to establish a login and re-run.") + print("\t Command : cmvclog -in ") exit_main(rc_cmvc) else: - print " CMVC Session Login : [ OK ] " + print(" CMVC Session Login : [ OK ] ") # Call API/Utility funcs def here #------------------------------ # 3) Check track status #------------------------------ - print "\n [ Checking CMVC track state ] " + print("\n [ Checking CMVC track state ] ") l_trackFix = utilcode.utilCheckTrackState(g_cmvc_num,release_name) if l_trackFix == errorcode.SUCCESS_TRACK_STATE : - print " Track in fix state. Suitable to continue." + print(" Track in fix state. Suitable to continue.") else : - print " Track not in fix state. Aborting activity." + print(" Track not in fix state. Aborting activity.") return errorcode.ERROR_TRACK_STATE #------------------------------ # 4) Checkout the code #------------------------------ - print "\n [ Creating Sandbox ]" + print("\n [ Creating Sandbox ]") origDir = os.getcwd() utilcode.utilCmvcChangeDir(g_cmvc_num) sbDir = os.getcwd() - print "\n [ Checkout Files from CMVC ] " - print " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + print("\n [ Checkout Files from CMVC ] ") + print(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") if file_name == "None": file_name = errorcode.CMVC_FILE_LIST for l_filename in file_name.split(","): rc_checkout = utilcode.utilCmvcCheckout(l_filename,release_name,g_cmvc_num) if rc_checkout == errorcode.ERROR_CMVC_CHECKOUT: - print " [ CMVC File Checkout Failed ] [Error code : %s]\t:%s"%(rc_checkout,l_filename) + print(" [ CMVC File Checkout Failed ] [Error code : %s]\t:%s"%(rc_checkout,l_filename)) # Undo checkout.. dont check errors just do it utilcode.utilRollBack("checkout",g_cmvc_num,release_name) # Return to initial directory of operation @@ -299,38 +300,38 @@ def main(): shutil.rmtree(sbDir) exit_main(rc_checkout) else: - print " CMVC File Checkout [ OK ]" - print " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + print(" CMVC File Checkout [ OK ]") + print(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") #------------------------------ # 4) Copy the binaries and file #------------------------------ # Find the files from the repo and copy to the Checkout dir - print "\n [ Find files and Overide the checkout file ] " - print " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + print("\n [ Find files and Overide the checkout file ] ") + print(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") rc_copy = utilcode.utilCmvcRepoPath(path_name,g_cmvc_num,file_name) if rc_copy == errorcode.ERROR_CMVC_FILE_COPY: - print " [ File copy Failed ] [ Error code : %s]"%rc_copy + print(" [ File copy Failed ] [ Error code : %s]"%rc_copy) # Return to initial directory of operation os.chdir(origDir) shutil.rmtree(sbDir) exit_main(rc_copy) else: - print " Files Copied Successfully : [ OK ] " + print(" Files Copied Successfully : [ OK ] ") - print " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + print(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") #--------------------- # 6) Checkin the files #--------------------- - print "\n [ Check-in Files from CMVC ] " - print " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + print("\n [ Check-in Files from CMVC ] ") + print(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") if file_name == "None": file_name = errorcode.CMVC_FILE_LIST for files in file_name.split(","): rc_checkin = utilcode.utilCmvcCheckin(files,release_name,g_cmvc_num) if rc_checkin == errorcode.ERROR_CMVC_CHECKIN: - print " [ CMVC File Checkin Failed ] [Error code : %s]\t:%s"%(rc_checkin,files) + print(" [ CMVC File Checkin Failed ] [Error code : %s]\t:%s"%(rc_checkin,files)) # Undo checkin.. dont check errors just do it utilcode.utilRollBack("checkin",g_cmvc_num,release_name) # Return to initial directory of operation @@ -338,28 +339,28 @@ def main(): shutil.rmtree(sbDir) exit_main(rc_checkin) else: - print " CMVC File Checkin [ OK ]" - print " ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" + print(" CMVC File Checkin [ OK ]") + print(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") #--------------------------------- # 7) Fix record the defect/release #--------------------------------- - print "\n [ Fix the Record to complete in CMVC ] " + print("\n [ Fix the Record to complete in CMVC ] ") utilcode.utilCmvcFixComplete(g_cmvc_num, release_name) #--------------------------------- # 8) Trigger Jenkins CI Job #--------------------------------- - print "\n [ Trigering Jenkins job ] " + print("\n [ Trigering Jenkins job ] ") rc_ci = utilcode.utilTriggerJenkins(g_cmvc_num, release_name, bvt) if rc_ci == errorcode.ERROR_CI_TRIGGER : - print " [ CI Trigger Failed ] [Error code : %s]\t"%(rc_ci) + print(" [ CI Trigger Failed ] [Error code : %s]\t"%(rc_ci)) # Return to initial directory of operation os.chdir(origDir) shutil.rmtree(sbDir) exit_main(rc_ci) else : - print " CI Trigger [ OK ]" + print(" CI Trigger [ OK ]") #----------------------------------------- # Return to initial directory of operation @@ -368,7 +369,7 @@ def main(): shutil.rmtree(sbDir) # Clean exit - print "\n [ Manually Integrate on CMVC post CI ] " + print("\n [ Manually Integrate on CMVC post CI ] ") exit_main(errorcode.SUCCESS_EXIT) diff --git a/src/tools/utils/cmvcRelease.py b/src/tools/utils/cmvcRelease.py index 6dd6b74c..4dc6e832 100755 --- a/src/tools/utils/cmvcRelease.py +++ b/src/tools/utils/cmvcRelease.py @@ -22,6 +22,7 @@ # permissions and limitations under the License. # # IBM_PROLOG_END_TAG +from __future__ import print_function import subprocess import os import sys @@ -42,7 +43,7 @@ CMVC_PASSWORD = "xxxxxx" # cmd = ['Feature','-open', '-remarks',' \"SBE release '+build_name+'\"', '-component', 'esw_sbei'] # result = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0] # cmvc_feature = result.split()[-1].split('.')[0] -# print "cmvc track ["+cmvc_feature+']' +# print("cmvc track ["+cmvc_feature+']') # os.system('Feature -assign '+cmvc_feature+' -owner '+CMVC_USER) # os.system('Feature -accept '+cmvc_feature) # os.system('Track -create -feature '+cmvc_feature+' -release fips911') @@ -77,46 +78,46 @@ def step_2(branch, cmvc_feature): filterarray += [ele] last_release = filterarray[-1].split()[0].split('/')[-1] - print "last release ["+last_release+"]" + print("last release ["+last_release+"]") # build-name generation cmd = [REL_TOOL,'build-name', '-release', RELEASE[branch]] build_name = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].split('\n')[0] - print "build name ["+build_name+"]" + print("build name ["+build_name+"]") # latest commit cmd = ['git','log', '-1', '--pretty=format:%H'] commit = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0].split('\n')[0] - print "commit ["+commit+"]" + print("commit ["+commit+"]") # define release level cmd = REL_TOOL+' define --level '+str(build_name)+' --base '+str(commit)+' --released '+str(last_release) os.system(cmd) - print cmd + print(cmd) # release cmd = REL_TOOL+' release --level '+build_name os.system(cmd) - print cmd + print(cmd) # make SBE cmd = 'make clean' - print cmd + print(cmd) os.system(cmd) cmd = 'make install' - print cmd + print(cmd) os.system(cmd) # trigger CI cmd = './sb cmvc -f '+str(cmvc_feature)+' -r ' + 'fips'+RELEASE[branch] os.system(cmd) - print cmd + print(cmd) # after ci pass def step_3(branch, track): # integrate track cmd = 'Track -integrate -feature '+track+' -release fips'+RELEASE[branch] os.system(cmd) - print cmd + print(cmd) # get last release tag cmd = ['git', 'for-each-ref', '--sort=taggerdate', '--format','\'%(refname) %(taggerdate)\'','refs/tags'] @@ -129,10 +130,10 @@ def step_3(branch, track): filterarray += [ele] last_release = filterarray[-1].split()[0].split('/')[-1] - print "last release ["+last_release+"]" + print("last release ["+last_release+"]") cmd = 'git push '+REMOTE+' '+last_release os.system(cmd) - print cmd + print(cmd) # cmvc log in diff --git a/src/tools/utils/sbeCmvcUtility.py b/src/tools/utils/sbeCmvcUtility.py index 405503e2..f5c02621 100755 --- a/src/tools/utils/sbeCmvcUtility.py +++ b/src/tools/utils/sbeCmvcUtility.py @@ -41,6 +41,7 @@ #------------------------- # Imports #------------------------- +from __future__ import print_function import os, sys import time import os.path @@ -66,7 +67,7 @@ import sbeCmvcConstants as errorcode def utilCmvcChangeDir(i_cmvcnum): l_home_path= expanduser("~") + "/" + errorcode.CMVC_DIR_CREATE + i_cmvcnum - print " Sandbox path\t: ",l_home_path + print(" Sandbox path\t: ",l_home_path) cmd='mkdir -p ' + l_home_path os.system(cmd) os.chdir(l_home_path) @@ -87,8 +88,8 @@ def utilCmvcRepoPath(i_pathname, i_cmvcnum, i_filename): l_home_path= expanduser("~") + "/" + errorcode.CMVC_DIR_CREATE + i_cmvcnum # Strip the last string from the file path input - print " Sandbox path\t: ",l_home_path - print " SBE Repo path\t: ",i_pathname + print(" Sandbox path\t: ",l_home_path) + print(" SBE Repo path\t: ",i_pathname) if i_filename == "None": i_filename = errorcode.CMVC_FILE_LIST @@ -100,10 +101,10 @@ def utilCmvcRepoPath(i_pathname, i_cmvcnum, i_filename): l_repo_path = utilFindFile(l_filename,i_pathname) if l_sb_path is None : - print " ERROR: Checked out sandbox does not contain " + l_filename + print(" ERROR: Checked out sandbox does not contain " + l_filename) return errorcode.ERROR_CMVC_FILE_COPY if l_repo_path is None : - print " ERROR: File Not Found in SBE repo " + l_filename + print(" ERROR: File Not Found in SBE repo " + l_filename) return errorcode.ERROR_CMVC_FILE_COPY cp_cmd = 'cp ' + l_repo_path + ' ' + l_sb_path @@ -180,8 +181,8 @@ def utilFindFilePPE(i_filename, i_path, i_sandbox_name): # ########################################################################## def utilCmvcCheckout(i_filename, i_release, i_cmvcnum): - print " File Name\t: ",i_filename - print " Release\t: ",i_release + print(" File Name\t: ",i_filename) + print(" Release\t: ",i_release) # The file simics.tar,releaseNotes.html is not unique so provide # the relative path @@ -190,7 +191,7 @@ def utilCmvcCheckout(i_filename, i_release, i_cmvcnum): elif i_filename == "releaseNotes.html": i_filename = 'src/sbei/sbfw/releaseNotes.html' - print " CMVC #\t: ",i_cmvcnum[1:] + print(" CMVC #\t: ",i_cmvcnum[1:]) l_home_path= expanduser("~") + "/" + errorcode.CMVC_DIR_CREATE + i_cmvcnum cmd='File -checkout ' + i_filename + ' -release '+ i_release + ' -relative ' + l_home_path @@ -199,12 +200,12 @@ def utilCmvcCheckout(i_filename, i_release, i_cmvcnum): else: cmd += ' -feature ' + i_cmvcnum[1:] - print " Executing\t: ", cmd + print(" Executing\t: ", cmd) rc = os.system(cmd) if rc: # rc 256 File not found in CMVC if rc == 256: - print " * File was not found or Error operation in CMVC" + print(" * File was not found or Error operation in CMVC") return errorcode.ERROR_CMVC_CHECKOUT else: return errorcode.SUCCESS_CMVC_CHECKOUT @@ -223,9 +224,9 @@ def utilCmvcCheckout(i_filename, i_release, i_cmvcnum): # ########################################################################## def utilCmvcCheckin(i_filename, i_release, i_cmvcnum): - print " File Name\t: ",i_filename - print " Release\t: ",i_release - print " CMVC #\t: ",i_cmvcnum[1:] + print(" File Name\t: ",i_filename) + print(" Release\t: ",i_release) + print(" CMVC #\t: ",i_cmvcnum[1:]) l_home_path= expanduser("~") + "/" + errorcode.CMVC_DIR_CREATE + i_cmvcnum l_base_path = utilFindFile(i_filename,l_home_path) @@ -240,7 +241,7 @@ def utilCmvcCheckin(i_filename, i_release, i_cmvcnum): else: cmd += ' -feature ' + i_cmvcnum[1:] - print " Executing\t: ", cmd + print(" Executing\t: ", cmd) rc = os.system(cmd) if rc: return errorcode.ERROR_CMVC_CHECKIN @@ -259,7 +260,7 @@ def utilCmvcCheckin(i_filename, i_release, i_cmvcnum): # ########################################################################## def utilCmvcFixComplete(i_cmvcnum, i_release): - print " CMVC #\t: ",i_cmvcnum + print(" CMVC #\t: ",i_cmvcnum) l_cmvcnum =i_cmvcnum[1:] if i_cmvcnum[:1] == "D": @@ -267,7 +268,7 @@ def utilCmvcFixComplete(i_cmvcnum, i_release): else: cmd='Fix -complete ' + ' -feature ' + l_cmvcnum + ' -r ' + i_release + ' -component esw_sbei' - print " Executing\t: ", cmd + print(" Executing\t: ", cmd) rc = os.system(cmd) if rc: return errorcode.ERROR_CMVC_FIX_RECORD @@ -285,8 +286,8 @@ def utilCmvcFixComplete(i_cmvcnum, i_release): # ########################################################################## def utilCheckTrackState(i_cmvcnum, i_release): - print " CMVC #\t: ",i_cmvcnum - print " Release\t: ",i_release + print(" CMVC #\t: ",i_cmvcnum) + print(" Release\t: ",i_release) l_cmvcnum =i_cmvcnum[1:] cmd = 'Track -view -release ' + i_release @@ -296,7 +297,7 @@ def utilCheckTrackState(i_cmvcnum, i_release): cmd += ' -feature ' + l_cmvcnum cmd += ' | grep state ' - print " Executing\t: ", cmd + print(" Executing\t: ", cmd) ex_cmd = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) for line in ex_cmd.stdout : if not line: continue @@ -316,24 +317,24 @@ def utilCheckTrackState(i_cmvcnum, i_release): # ########################################################################## def utilCheckFileHash(i_src, i_dest): - print " Source\t: ",i_src - print " Destination\t: ",i_dest + print(" Source\t: ",i_src) + print(" Destination\t: ",i_dest) sha_orig = hashlib.sha256() sha_orig.update(file(i_src).read()) orig_hash=sha_orig.hexdigest() - print " * Orig Hash\t [ %s : %s ] "% (os.path.basename(i_src),orig_hash) + print(" * Orig Hash\t [ %s : %s ] "% (os.path.basename(i_src),orig_hash)) sha_copy = hashlib.sha256() sha_copy.update(file(i_dest).read()) copied_hash=sha_copy.hexdigest() - print " * Copied Hash\t [ %s : %s ] "% (os.path.basename(i_dest),copied_hash) + print(" * Copied Hash\t [ %s : %s ] "% (os.path.basename(i_dest),copied_hash)) if orig_hash == copied_hash: - print " -> Hash Match .. Continue\n" + print(" -> Hash Match .. Continue\n") return errorcode.SUCCESS_HASH_CHECK else: - print " Mismatch Hash.. Abort" + print(" Mismatch Hash.. Abort") return errorcode.ERROR_HASH_CHECK ########################################################################## @@ -349,27 +350,27 @@ def utilCheckFileHash(i_src, i_dest): # ########################################################################## def utilRollBack(i_action, i_cmvcnum, i_release): - print "\n * Action request\t: ",i_action + print("\n * Action request\t: ",i_action) if i_action == "checkin": - print " * Undoing All default File list" + print(" * Undoing All default File list") if i_cmvcnum[:1] == "D": cmd = 'File -undo ' + errorcode.CMVC_FILE_UNDO_LIST + ' -release ' + i_release + ' -defect ' + i_cmvcnum[1:] + ' >/dev/null 2>&1' else: cmd = 'File -undo ' + errorcode.CMVC_FILE_UNDO_LIST + ' -release ' + i_release + ' -feature ' + i_cmvcnum[1:] + ' >/dev/null 2>&1' else: - print " * Unlocking All default Files list" + print(" * Unlocking All default Files list") if i_cmvcnum[:1] == "D": cmd = 'File -unlock ' + errorcode.CMVC_FILE_UNDO_LIST + ' -release ' + i_release + ' >/dev/null 2>&1' else: cmd = 'File -unlock ' + errorcode.CMVC_FILE_UNDO_LIST + ' -release ' + i_release + ' >/dev/null 2>&1' - #print " Executing : ", cmd + #print(" Executing : ", cmd) rc = os.system(cmd) # CMVC throws this rc even if its successfull if rc != 1024 and rc !=0: - print "\n Error [ %s ] in Undoing/Unlocking Files.. Please check manually"%rc + print("\n Error [ %s ] in Undoing/Unlocking Files.. Please check manually"%rc) else: - print "\n Roll Back Successfull.. Please Revisit your inputs [ OK ] " + print("\n Roll Back Successfull.. Please Revisit your inputs [ OK ] ") ########################################################################## @@ -385,7 +386,7 @@ def utilRollBack(i_action, i_cmvcnum, i_release): # ########################################################################## def utilTriggerJenkins(i_cmvcnum,i_release,i_bvt): - print " Jenkins job for %s" % i_cmvcnum + print(" Jenkins job for %s" % i_cmvcnum) #PATH : /afs/austin.ibm.com/projects/esw/bin/fsp-CI-jenkins cmd = "fsp-CI-jenkins -r " + i_release + " -t " + i_cmvcnum[1:] + " --test_on_hardware=y" if not i_bvt == "None" : @@ -411,14 +412,14 @@ def utilTriggerJenkins(i_cmvcnum,i_release,i_bvt): ########################################################################## def utilCopyFileToSandbox(i_pathname,i_sandboxname,i_filename): - print "\n *** For Development *** \n" - print " Sandbox path\t: ",i_sandboxname - print " SBE Repo path\t: ",i_pathname - print "\n" + print("\n *** For Development *** \n") + print(" Sandbox path\t: ",i_sandboxname) + print(" SBE Repo path\t: ",i_pathname) + print("\n") if i_filename == "None": i_filename = errorcode.CMVC_FILE_LIST - #print " No User supplied Files to copy" + #print(" No User supplied Files to copy") #return errorcode.ERROR_FILE_INPUT for l_filename in i_filename.split(","): @@ -426,7 +427,7 @@ def utilCopyFileToSandbox(i_pathname,i_sandboxname,i_filename): l_sandbox_name = os.path.basename(i_sandboxname) l_repo_path = utilFindFilePPE(l_filename,i_pathname,l_sandbox_name) if l_repo_path is None : - print " File [ %s ] not found in Repo..\t Check your repo and retry "%l_filename + print(" File [ %s ] not found in Repo..\t Check your repo and retry "%l_filename) return errorcode.ERROR_CMVC_FILE_COPY else: for files in errorcode.FILE_LOOKUP_LIST.split(","): @@ -439,18 +440,18 @@ def utilCopyFileToSandbox(i_pathname,i_sandboxname,i_filename): # Check if this path exist in the sandbox , if not create and copy if os.path.exists(sb_cp_path) == False: cmd='mkdir -p ' + os.path.dirname(sb_cp_path) - #print " Creating dir %s "%cmd + #print(" Creating dir %s "%cmd) os.system(cmd) # Copy the file copy_cmd = 'cp -rf ' + l_repo_path + ' ' + sb_cp_path rc = os.system(copy_cmd) if rc: - print " RC code :",rc - print " ERROR : Copying file : ",copy_cmd + print(" RC code :",rc) + print(" ERROR : Copying file : ",copy_cmd) return errorcode.ERROR_CMVC_FILE_COPY else: - print " Copied file : ",copy_cmd + print(" Copied file : ",copy_cmd) return errorcode.SUCCESS_DEV_EXIT @@ -471,15 +472,15 @@ def utilppeSbENV(i_env_key): env_ppe_path="None" for key in os.environ.keys(): if i_env_key in key: - #print "\t %s : %s" % (key,os.environ[key]) + #print("\t %s : %s" % (key,os.environ[key])) env_ppe_path = os.environ[key] l_found_ppe_conf = True if l_found_ppe_conf == False: - print " ---------------------------------------------------------" - print " | [ ERROR SETTING ] : The PPE Repository ENV is not set |" - print " | Please do ./sb workon to set/load the PPE repo ENV |" - print " ---------------------------------------------------------" + print(" ---------------------------------------------------------") + print(" | [ ERROR SETTING ] : The PPE Repository ENV is not set |") + print(" | Please do ./sb workon to set/load the PPE repo ENV |") + print(" ---------------------------------------------------------") return env_ppe_path diff --git a/src/tools/utils/sbePatchUtility.py b/src/tools/utils/sbePatchUtility.py index bbb6d883..2ab1ecaa 100644 --- a/src/tools/utils/sbePatchUtility.py +++ b/src/tools/utils/sbePatchUtility.py @@ -40,6 +40,7 @@ #------------------------- # Imports #------------------------- +from __future__ import print_function import os, sys import time import os.path @@ -65,7 +66,7 @@ import sbeCmvcUtility as utilcode # ########################################################################## def utilPatchSimics(i_sandbox_path, i_sandbox_root): - print "\n ... Patching simics files " + print("\n ... Patching simics files ") sb_name=os.path.basename(i_sandbox_path) @@ -76,7 +77,7 @@ def utilPatchSimics(i_sandbox_path, i_sandbox_root): return errorcode.ERROR_HOOKING_FILE l_sim_cmd = "workon -m ppc " + sb_name + " -c " + l_sim_file + " -rc " + i_sandbox_root +"/sbesandboxrc" - print " ", l_sim_cmd + print(" ", l_sim_cmd) os.system(l_sim_cmd) @@ -96,7 +97,7 @@ def utilPatchSimics(i_sandbox_path, i_sandbox_root): # ########################################################################## def utilExecuteShell(i_ppe_root, i_sandbox_path, i_shell_file): - print "\n ... Executing shell : ",i_shell_file + print("\n ... Executing shell : ",i_shell_file) # Sanbox name if i_sandbox_path != "None": @@ -105,7 +106,7 @@ def utilExecuteShell(i_ppe_root, i_sandbox_path, i_shell_file): # Find the file and execute l_path_name = i_ppe_root + '/src' l_shell_path=utilcode.utilFindFile(i_shell_file, l_path_name) - print " [ %s ]"%l_shell_path + print(" [ %s ]"%l_shell_path) if i_sandbox_path != "None": # Load the shell onto the Sandbox env and execute @@ -132,7 +133,7 @@ def utilExecuteShell(i_ppe_root, i_sandbox_path, i_shell_file): def utilShell_hooks(i_sandbox_path): # Find the simics machine from ENV l_machine = os.environ['MACHINE'].rstrip('\n') - print " Machine : ",l_machine + print(" Machine : ",l_machine) l_cmd_exec = 'start_simics -no_start -machine ' + l_machine + ' -batch_mode ' # Write the compile shell hook on the fips sandbox location diff --git a/src/tools/utils/sbePrime.py b/src/tools/utils/sbePrime.py index 8f522bda..dd3ab153 100755 --- a/src/tools/utils/sbePrime.py +++ b/src/tools/utils/sbePrime.py @@ -41,6 +41,7 @@ #------------------------- # Imports #------------------------- +from __future__ import print_function import getopt import os, sys, glob import shutil @@ -60,49 +61,49 @@ def main(): # Usage tool option #------------------------------------------ def usage(): - print " \n" - print " :: Command line USAGE options for Copying SBE FW files for compilation :: \n" - print " sbeDistribute.py -s -i " - - print " \n" - print " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" - print " | By default NO argument is needed as an input . |" - print " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" - print " \n ***** Options Supported *****" - print " \t -p,--patch = [ Optional ] Patch Simics related files on Sandbox " - print " \t -s,--sb = [ Optional ] Sandbox base name" - print " \t By default it picks up the ppe Repo test_sb sandbox" - print " \t but if you have created a sandbox of your own manually " - print " \t and you want to compile, use this option then only" - print " \t -i,--files = [ Optional ] Firmware Files coma ',' separated input file1,file2" - print " \t Only the pre-define listed files bellow:" - print " \t sbe_sp_intf.H,simics.tar," - print " \t sbe_seeprom_DD2.bin" - print " \t -r,--rc_file = [ Optional ] The RC file for the sandbox (with absolute path)" - print " \t -n,--no_build = [ Optional ] Flag to determine if sbei component should be compiled" - print " \t -h,--help = Help" - print " ------------------------------------------------------------------------------------" + print(" \n") + print(" :: Command line USAGE options for Copying SBE FW files for compilation :: \n") + print(" sbeDistribute.py -s -i ") + + print(" \n") + print(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") + print(" | By default NO argument is needed as an input . |") + print(" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++") + print(" \n ***** Options Supported *****") + print(" \t -p,--patch = [ Optional ] Patch Simics related files on Sandbox ") + print(" \t -s,--sb = [ Optional ] Sandbox base name") + print(" \t By default it picks up the ppe Repo test_sb sandbox") + print(" \t but if you have created a sandbox of your own manually ") + print(" \t and you want to compile, use this option then only") + print(" \t -i,--files = [ Optional ] Firmware Files coma ',' separated input file1,file2") + print(" \t Only the pre-define listed files bellow:") + print(" \t sbe_sp_intf.H,simics.tar,") + print(" \t sbe_seeprom_DD2.bin") + print(" \t -r,--rc_file = [ Optional ] The RC file for the sandbox (with absolute path)") + print(" \t -n,--no_build = [ Optional ] Flag to determine if sbei component should be compiled") + print(" \t -h,--help = Help") + print(" ------------------------------------------------------------------------------------") #------------------------------------------ # Exit from this Main #------------------------------------------ def exit_main(rc): if rc == errorcode.HELP_EXIT: - print " [ HELP DOCUMENTATION ]\n" + print(" [ HELP DOCUMENTATION ]\n") sys.exit(0) if rc == errorcode.ERROR_BUILD_FAILED: - print " Compilation Failed .. Error " + print(" Compilation Failed .. Error ") if rc == errorcode.SUCCESS_DEV_EXIT: - print " [ Files Copy done! ]\n" + print(" [ Files Copy done! ]\n") sys.exit(0) if rc: - print "\n [ ERROR - MAIN ] Exiting with error code = ", rc + print("\n [ ERROR - MAIN ] Exiting with error code = ", rc) sys.exit(rc) else: - print "\n Fips Sandbox compilation and simics patching completed [ OK ] " + print("\n Fips Sandbox compilation and simics patching completed [ OK ] ") sys.exit(0) #------------------------------------------ @@ -154,17 +155,17 @@ def main(): #------------------------------ # 1) User input params/ Check ENV #------------------------------ - print "\n [ Checking SBE user ENV Pre-req ] " + print("\n [ Checking SBE user ENV Pre-req ] ") # Get it from ENV if path_name == "None": # Get the PPE path l_ppe_path = utilcode.utilppeSbENV("SBEROOT") if l_ppe_path == "None": - print "\n Couldn't find PPE repo info from ENV currently set... " - print " [ ERROR ] PPE Repo ENV Setting Path : %s " % l_ppe_path + print("\n Couldn't find PPE repo info from ENV currently set... ") + print(" [ ERROR ] PPE Repo ENV Setting Path : %s " % l_ppe_path) exit_main(errorcode.ERROR_SETTING) else: - print " PPE Repo path Setting\t : %s "% l_ppe_path + print(" PPE Repo path Setting\t : %s "% l_ppe_path) path_name = l_ppe_path #----------------------------------- @@ -177,7 +178,7 @@ def main(): sandbox_path = utilcode.utilFind_ENV_string("SANDBOXBASE").rstrip('\n') else: sandbox_path = utilcode.utilFind_sb_base(sandbox_name).rstrip('\n') - print " Fips Sandbox path\t : ",sandbox_path + print(" Fips Sandbox path\t : ",sandbox_path) #----------------------------------- # 3) Get the Sanbox root path @@ -189,11 +190,11 @@ def main(): sandbox_root = utilcode.utilFind_sb_rc(sandbox_name).rstrip('\n') if sandbox_root == "None": - print " ** [ ERROR ] Something Fishy about the ENV set -OR- Option used.. Please check manually ** " + print(" ** [ ERROR ] Something Fishy about the ENV set -OR- Option used.. Please check manually ** ") usage() exit_main(errorcode.ERROR_SETTING) else: - print " Sandbox root path\t : ",sandbox_root + print(" Sandbox root path\t : ",sandbox_root) #--------------------------------------------- # sim setup if user initiates @@ -204,22 +205,22 @@ def main(): #--------------------------------------------- rc_sb = utilpatch.utilExecuteShell(path_name,"None","sandbox-create") if rc_sb == errorcode.SUCCESS_EXIT: - print " Sandbox Created.. [ OK ] \n" + print(" Sandbox Created.. [ OK ] \n") else: - print " Sandbox Create.. [ ERROR ]",rc_sb + print(" Sandbox Create.. [ ERROR ]",rc_sb) exit_main(rc_sb) #---------------------------------------- # Patch up the simics patches files #---------------------------------------- - print "\n *** Update Simics patches onto Sandbox *** \n " + print("\n *** Update Simics patches onto Sandbox *** \n ") # Pre sim setup rc_shell = utilpatch.utilExecuteShell(path_name,sandbox_path,"workarounds.presimsetup") if rc_shell == errorcode.SUCCESS_EXIT: - print " presimsetup [ OK ]\n" + print(" presimsetup [ OK ]\n") else: - print " presimsetup [ ERROR ] : ",rc_shell + print(" presimsetup [ ERROR ] : ",rc_shell) exit_main(rc_shell) # Patch the simics files @@ -227,16 +228,16 @@ def main(): if rc_sim != errorcode.SUCCESS_EXIT: exit_main(rc_sim) else: - print " Patch the simics files on Sandbox [ OK ] \n" + print(" Patch the simics files on Sandbox [ OK ] \n") # Post sim setup rc_shell = utilpatch.utilExecuteShell(path_name,sandbox_path,"workarounds.postsimsetup") if rc_shell == errorcode.SUCCESS_EXIT: - print " postsimsetup [ OK ]\n" + print(" postsimsetup [ OK ]\n") # Clean exit Get out from here exit_main(errorcode.SUCCESS_EXIT) else: - print " postsimsetup [ ERROR ] : ",rc_shell + print(" postsimsetup [ ERROR ] : ",rc_shell) exit_main(rc_shell) # Files to copy for sbe prime @@ -257,22 +258,22 @@ def main(): if os.path.isdir(sandbox_path) == True: rc_copy = utilcode.utilCopyFileToSandbox(path_name,sandbox_path,file_name) if rc_copy == errorcode.SUCCESS_DEV_EXIT: - print " Files Copied to Fips Sandbox : [ OK ]" + print(" Files Copied to Fips Sandbox : [ OK ]") else: exit_main(rc_copy) else: - print " Sandbox : %s [ Either doesn't exist or do workon to fips sb to load the ENV.. ]" % os.path.basename(sandbox_path) - print " - OR - " - print " [ Optional ] You can specify your sandbox name as input as well" - print " -s " + print(" Sandbox : %s [ Either doesn't exist or do workon to fips sb to load the ENV.. ]" % os.path.basename(sandbox_path)) + print(" - OR - ") + print(" [ Optional ] You can specify your sandbox name as input as well") + print(" -s ") usage() exit_main(errorcode.ERROR_SANDBOX_EXIST) else: - print " Please Check your fips Sandbox and retry" + print(" Please Check your fips Sandbox and retry") exit_main(errorcode.ERROR_SANDBOX_EXIST) sb_name=os.path.basename(sandbox_path) - print "\n Sandbox :",sb_name + print("\n Sandbox :",sb_name) if build == "1": #---------------------------------------- @@ -291,12 +292,12 @@ def main(): if rc_file == "None": compile_cmd="workon -m ppc " + sb_name + " -c " + hook_file + " -rc " + sandbox_root +"/.sandboxrc" else: - print " getting rc file from user \n" + print(" getting rc file from user \n") compile_cmd="workon -m ppc " + sb_name + " -c " + hook_file + " -rc " + rc_file - print "\n [ COMPILE ] Executing :%s \n"%compile_cmd + print("\n [ COMPILE ] Executing :%s \n"%compile_cmd) rc = os.system(compile_cmd) - print " Compilation returned rc :",rc + print(" Compilation returned rc :",rc) if rc != 0: exit_main(errorcode.ERROR_BUILD_FAILED) -- cgit v1.2.1