Refactor print statements to be compatible with python 3.
Based on "futurize -f libfuturize.fixes.fix_print_with_import"
Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
#
# ExceptionList if a tool takes an argument with a / add it to the exception list
#
+from __future__ import print_function\r
import sys
import os
import subprocess
ret = main(sys.argv[2:])
except:
- print "exiting: exception from " + sys.argv[0]
+ print("exiting: exception from " + sys.argv[0])\r
ret = 2
sys.exit(ret)
'''\r
BinToPcd\r
'''\r
+from __future__ import print_function\r
\r
import sys\r
import argparse\r
#\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import argparse\r
import os\r
import os.path\r
#\r
##\r
\r
+from __future__ import print_function\r
import os\r
import re\r
import sys\r
try:\r
nmCommand = "nm"\r
nmLineOption = "-l"\r
- print "parsing (debug) - " + pdbName\r
+ print("parsing (debug) - " + pdbName)\r
os.system ('%s %s %s > nmDump.line.log' % (nmCommand, nmLineOption, pdbName))\r
except :\r
- print 'ERROR: nm command not available. Please verify PATH'\r
+ print('ERROR: nm command not available. Please verify PATH')\r
return\r
\r
#\r
DIA2DumpCommand = "Dia2Dump.exe"\r
#DIA2SymbolOption = "-p"\r
DIA2LinesOption = "-l"\r
- print "parsing (pdb) - " + pdbName\r
+ print("parsing (pdb) - " + pdbName)\r
#os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpCommand, DIA2SymbolOption, pdbName))\r
os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, DIA2LinesOption, pdbName))\r
except :\r
- print 'ERROR: DIA2Dump command not available. Please verify PATH'\r
+ print('ERROR: DIA2Dump command not available. Please verify PATH')\r
return\r
\r
#\r
try :\r
file = open(Options.inputfilename)\r
except Exception:\r
- print "fail to open " + Options.inputfilename\r
+ print("fail to open " + Options.inputfilename)\r
return 1\r
try :\r
newfile = open(Options.outputfilename, "w")\r
except Exception:\r
- print "fail to open " + Options.outputfilename\r
+ print("fail to open " + Options.outputfilename)\r
return 1\r
\r
try:\r
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
#\r
\r
+from __future__ import print_function\r
import os, sys, logging, traceback, subprocess\r
from optparse import OptionParser\r
\r
default = "C:\\Program Files\\doxygen\\bin\\doxygen.exe"\r
if options.DoxygenPath is None:\r
if os.path.exists(default):\r
- print "Warning: Assume doxygen tool is installed at %s. If not, please specify via -x" % default\r
+ print("Warning: Assume doxygen tool is installed at %s. If not, please specify via -x" % default)\r
options.DoxygenPath = default\r
else:\r
errors.append('- Please specify the path of doxygen tool installation via option -x! or install it in default path %s' % default)\r
if options.PackagePath is not None and os.path.exists(options.PackagePath):\r
dirpath = os.path.dirname(options.PackagePath)\r
default = os.path.join (dirpath, "Document")\r
- print 'Warning: Assume document output at %s. If not, please specify via option -o' % default\r
+ print('Warning: Assume document output at %s. If not, please specify via option -o' % default)\r
options.OutputPath = default\r
if not os.path.exists(default):\r
try:\r
\r
if options.Arch is None:\r
options.Arch = 'ALL'\r
- print "Warning: Assume arch is \"ALL\". If not, specify via -a"\r
+ print("Warning: Assume arch is \"ALL\". If not, specify via -a")\r
\r
if options.DocumentMode is None:\r
options.DocumentMode = "HTML"\r
- print "Warning: Assume document mode is \"HTML\". If not, specify via -m"\r
+ print("Warning: Assume document mode is \"HTML\". If not, specify via -m")\r
\r
if options.IncludeOnly is None:\r
options.IncludeOnly = False\r
- print "Warning: Assume generate package document for all package\'s source including publich interfaces and implementation libraries and modules."\r
+ print("Warning: Assume generate package document for all package\'s source including publich interfaces and implementation libraries and modules.")\r
\r
if options.DocumentMode.lower() == 'chm':\r
default = "C:\\Program Files\\HTML Help Workshop\\hhc.exe"\r
if options.HtmlWorkshopPath is None:\r
if os.path.exists(default):\r
- print 'Warning: Assume the installation path of Microsoft HTML Workshop is %s. If not, specify via option -c.' % default\r
+ print('Warning: Assume the installation path of Microsoft HTML Workshop is %s. If not, specify via option -c.' % default)\r
options.HtmlWorkshopPath = default\r
else:\r
errors.append('- Please specify the installation path of Microsoft HTML Workshop via option -c!')\r
errors.append('- The installation path of Microsoft HTML Workshop %s does not exists. ' % options.HtmlWorkshopPath)\r
\r
if len(errors) != 0:\r
- print '\n'\r
+ print('\n')\r
parser.error('Fail to start due to following reasons: \n%s' %'\n'.join(errors))\r
return (options.WorkspacePath, options.PackagePath, options.DoxygenPath, options.OutputPath,\r
options.Arch, options.DocumentMode, options.IncludeOnly, options.HtmlWorkshopPath)\r
return pkgObj\r
\r
def callbackLogMessage(msg, level):\r
- print msg.strip()\r
+ print(msg.strip())\r
\r
def callbackCreateDoxygenProcess(doxPath, configPath):\r
if sys.platform == 'win32':\r
cmd = '"%s" %s' % (doxPath, configPath)\r
else:\r
cmd = '%s %s' % (doxPath, configPath)\r
- print cmd\r
+ print(cmd)\r
subprocess.call(cmd, shell=True)\r
\r
\r
def DocumentFixup(outPath, arch):\r
# find BASE_LIBRARY_JUMP_BUFFER structure reference page\r
\r
- print '\n >>> Start fixup document \n'\r
+ print('\n >>> Start fixup document \n')\r
\r
for root, dirs, files in os.walk(outPath):\r
for dir in dirs:\r
if text.find('MdePkg/Include/Library/UefiApplicationEntryPoint.h File Reference') != -1:\r
FixPageUefiApplicationEntryPoint(fullpath, text)\r
\r
- print ' >>> Finish all document fixing up! \n'\r
+ print(' >>> Finish all document fixing up! \n')\r
\r
def FixPageBaseLib(path, text):\r
- print ' >>> Fixup BaseLib file page at file %s \n' % path\r
+ print(' >>> Fixup BaseLib file page at file %s \n' % path)\r
lines = text.split('\n')\r
lastBaseJumpIndex = -1\r
lastIdtGateDescriptor = -1\r
except:\r
logging.getLogger().error(" <<< Fail to fixup file %s\n" % path)\r
return\r
- print " <<< Finish to fixup file %s\n" % path\r
+ print(" <<< Finish to fixup file %s\n" % path)\r
\r
def FixPageIA32_IDT_GATE_DESCRIPTOR(path, text):\r
- print ' >>> Fixup structure reference IA32_IDT_GATE_DESCRIPTOR at file %s \n' % path\r
+ print(' >>> Fixup structure reference IA32_IDT_GATE_DESCRIPTOR at file %s \n' % path)\r
lines = text.split('\n')\r
for index in range(len(lines) - 1, -1, -1):\r
line = lines[index].strip()\r
except:\r
logging.getLogger().error(" <<< Fail to fixup file %s\n" % path)\r
return\r
- print " <<< Finish to fixup file %s\n" % path\r
+ print(" <<< Finish to fixup file %s\n" % path)\r
\r
def FixPageBASE_LIBRARY_JUMP_BUFFER(path, text):\r
- print ' >>> Fixup structure reference BASE_LIBRARY_JUMP_BUFFER at file %s \n' % path\r
+ print(' >>> Fixup structure reference BASE_LIBRARY_JUMP_BUFFER at file %s \n' % path)\r
lines = text.split('\n')\r
bInDetail = True\r
bNeedRemove = False\r
except:\r
logging.getLogger().error(" <<< Fail to fixup file %s" % path)\r
return\r
- print " <<< Finish to fixup file %s\n" % path\r
+ print(" <<< Finish to fixup file %s\n" % path)\r
\r
def FixPageUefiDriverEntryPoint(path, text):\r
- print ' >>> Fixup file reference MdePkg/Include/Library/UefiDriverEntryPoint.h at file %s \n' % path\r
+ print(' >>> Fixup file reference MdePkg/Include/Library/UefiDriverEntryPoint.h at file %s \n' % path)\r
lines = text.split('\n')\r
bInModuleEntry = False\r
bInEfiMain = False\r
except:\r
logging.getLogger().error(" <<< Fail to fixup file %s" % path)\r
return\r
- print " <<< Finish to fixup file %s\n" % path\r
+ print(" <<< Finish to fixup file %s\n" % path)\r
\r
\r
def FixPageUefiApplicationEntryPoint(path, text):\r
- print ' >>> Fixup file reference MdePkg/Include/Library/UefiApplicationEntryPoint.h at file %s \n' % path\r
+ print(' >>> Fixup file reference MdePkg/Include/Library/UefiApplicationEntryPoint.h at file %s \n' % path)\r
lines = text.split('\n')\r
bInModuleEntry = False\r
bInEfiMain = False\r
except:\r
logging.getLogger().error(" <<< Fail to fixup file %s" % path)\r
return\r
- print " <<< Finish to fixup file %s\n" % path\r
+ print(" <<< Finish to fixup file %s\n" % path)\r
\r
if __name__ == '__main__':\r
wspath, pkgpath, doxpath, outpath, archtag, docmode, isinc, hwpath = parseCmdArgs()\r
else:\r
cmd = '%s %s' % (hwpath, indexpath)\r
subprocess.call(cmd)\r
- print '\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.chm')\r
+ print('\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.chm'))\r
else:\r
- print '\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.html')\r
+ print('\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.html'))\r
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
#\r
\r
+from __future__ import print_function\r
import os\r
\r
from message import *\r
p.AddPage(Page('PCD', 'pcds'))\r
\r
df.Generate()\r
- print df\r
+ print(df)\r
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
#\r
\r
+from __future__ import print_function\r
import array\r
import uuid\r
import re\r
return list2int(self._arr.tolist()[48:50])\r
\r
def Dump(self):\r
- print 'Signature: %s' % self.GetSigunature()\r
- print 'Attribute: 0x%X' % self.GetAttribute()\r
- print 'Header Length: 0x%X' % self.GetHeaderLength()\r
- print 'File system Guid: ', self.GetFileSystemGuid()\r
- print 'Revision: 0x%X' % self.GetRevision()\r
- print 'FvLength: 0x%X' % self.GetFvLength()\r
+ print('Signature: %s' % self.GetSigunature())\r
+ print('Attribute: 0x%X' % self.GetAttribute())\r
+ print('Header Length: 0x%X' % self.GetHeaderLength())\r
+ print('File system Guid: ', self.GetFileSystemGuid())\r
+ print('Revision: 0x%X' % self.GetRevision())\r
+ print('FvLength: 0x%X' % self.GetFvLength())\r
\r
def GetFileSystemGuid(self):\r
list = self._arr.tolist()\r
line.append('0x%X' % int(item))\r
count += 1\r
else:\r
- print ' '.join(line)\r
+ print(' '.join(line))\r
count = 0\r
line = []\r
line.append('0x%X' % int(item))\r
return 'Unknown Ffs State'\r
\r
def Dump(self):\r
- print "FFS name: ", self.GetNameGuid()\r
- print "FFS type: ", self.GetType()\r
- print "FFS attr: 0x%X" % self.GetAttributes()\r
- print "FFS size: 0x%X" % self.GetFfsSize()\r
- print "FFS state: 0x%X" % self.GetState()\r
+ print("FFS name: ", self.GetNameGuid())\r
+ print("FFS type: ", self.GetType())\r
+ print("FFS attr: 0x%X" % self.GetAttributes())\r
+ print("FFS size: 0x%X" % self.GetFfsSize())\r
+ print("FFS state: 0x%X" % self.GetState())\r
\r
def GetRawData(self):\r
return self._arr.tolist()\r
return self.section_type_map[type]\r
\r
def Dump(self):\r
- print 'size = 0x%X' % self.GetSectionSize()\r
- print 'type = 0x%X' % self.GetType()\r
+ print('size = 0x%X' % self.GetSectionSize())\r
+ print('type = 0x%X' % self.GetType())\r
\r
\r
\r
#\r
##\r
\r
+from __future__ import print_function\r
import os\r
import re\r
import sys\r
try:\r
nmCommand = "nm"\r
nmLineOption = "-l"\r
- print "parsing (debug) - " + pdbName\r
+ print("parsing (debug) - " + pdbName)\r
os.system ('%s %s %s > nmDump.line.log' % (nmCommand, nmLineOption, pdbName))\r
except :\r
- print 'ERROR: nm command not available. Please verify PATH'\r
+ print('ERROR: nm command not available. Please verify PATH')\r
return\r
\r
#\r
DIA2DumpCommand = "Dia2Dump.exe"\r
#DIA2SymbolOption = "-p"\r
DIA2LinesOption = "-l"\r
- print "parsing (pdb) - " + pdbName\r
+ print("parsing (pdb) - " + pdbName)\r
#os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpCommand, DIA2SymbolOption, pdbName))\r
os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, DIA2LinesOption, pdbName))\r
except :\r
- print 'ERROR: DIA2Dump command not available. Please verify PATH'\r
+ print('ERROR: DIA2Dump command not available. Please verify PATH')\r
return\r
\r
#\r
try :\r
DOMTree = xml.dom.minidom.parse(Options.inputfilename)\r
except Exception:\r
- print "fail to open input " + Options.inputfilename\r
+ print("fail to open input " + Options.inputfilename)\r
return 1\r
\r
if Options.guidreffilename is not None:\r
try :\r
guidreffile = open(Options.guidreffilename)\r
except Exception:\r
- print "fail to open guidref" + Options.guidreffilename\r
+ print("fail to open guidref" + Options.guidreffilename)\r
return 1\r
genGuidString(guidreffile)\r
guidreffile.close()\r
\r
Handler = smiHandler.getElementsByTagName("Handler")\r
RVA = Handler[0].getElementsByTagName("RVA")\r
- print " Handler RVA: %s" % RVA[0].childNodes[0].data\r
+ print(" Handler RVA: %s" % RVA[0].childNodes[0].data)\r
\r
if (len(RVA)) >= 1:\r
rvaName = RVA[0].childNodes[0].data\r
\r
Caller = smiHandler.getElementsByTagName("Caller")\r
RVA = Caller[0].getElementsByTagName("RVA")\r
- print " Caller RVA: %s" % RVA[0].childNodes[0].data\r
+ print(" Caller RVA: %s" % RVA[0].childNodes[0].data)\r
\r
if (len(RVA)) >= 1:\r
rvaName = RVA[0].childNodes[0].data\r
try :\r
newfile = open(Options.outputfilename, "w")\r
except Exception:\r
- print "fail to open output" + Options.outputfilename\r
+ print("fail to open output" + Options.outputfilename)\r
return 1\r
\r
newfile.write(DOMTree.toprettyxml(indent = "\t", newl = "\n", encoding = "utf-8"))\r
\r
## Import Modules\r
#\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os\r
import re\r
import os.path as path\r
os.makedirs(self.BuildDir)\r
with open(os.path.join(self.BuildDir, 'AutoGen'), 'w+') as file:\r
for f in AllWorkSpaceMetaFiles:\r
- print >> file, f\r
+ print(f, file=file)\r
return True\r
\r
def _GenPkgLevelHash(self, Pkg):\r
os.remove (self.GetTimeStampPath())\r
with open(self.GetTimeStampPath(), 'w+') as file:\r
for f in FileSet:\r
- print >> file, f\r
+ print(f, file=file)\r
\r
Module = property(_GetModule)\r
Name = property(_GetBaseName)\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os\r
import re\r
import copy\r
EdkLogger.Initialize()\r
if len(sys.argv) > 1:\r
Br = BuildRule(sys.argv[1])\r
- print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "MSFT"][1])\r
- print\r
- print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "INTEL"][1])\r
- print\r
- print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "GCC"][1])\r
- print\r
- print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])\r
- print\r
- print str(Br[".h", "ACPI_TABLE", "IA32", "INTEL"][1])\r
- print\r
- print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])\r
- print\r
- print str(Br[".s", SUP_MODULE_SEC, "IPF", "COMMON"][1])\r
- print\r
- print str(Br[".s", SUP_MODULE_SEC][1])\r
+ print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "MSFT"][1]))\r
+ print()\r
+ print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "INTEL"][1]))\r
+ print()\r
+ print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "GCC"][1]))\r
+ print()\r
+ print(str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1]))\r
+ print()\r
+ print(str(Br[".h", "ACPI_TABLE", "IA32", "INTEL"][1]))\r
+ print()\r
+ print(str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1]))\r
+ print()\r
+ print(str(Br[".s", SUP_MODULE_SEC, "IPF", "COMMON"][1]))\r
+ print()\r
+ print(str(Br[".s", SUP_MODULE_SEC][1]))\r
\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os, codecs, re\r
import distutils.util\r
import Common.EdkLogger as EdkLogger\r
# Show the instance itself\r
#\r
def ShowMe(self):\r
- print self.LanguageDef\r
+ print(self.LanguageDef)\r
#print self.OrderedStringList\r
for Item in self.OrderedStringList:\r
- print Item\r
+ print(Item)\r
for Member in self.OrderedStringList[Item]:\r
- print str(Member)\r
+ print(str(Member))\r
\r
# This acts like the main() function for the script, unless it is 'import'ed into another\r
# script.\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os\r
import sys\r
import encodings.ascii\r
#\r
def StartBpdg(InputFileName, MapFileName, VpdFileName, Force):\r
if os.path.exists(VpdFileName) and not Force:\r
- print "\nFile %s already exist, Overwrite(Yes/No)?[Y]: " % VpdFileName\r
+ print("\nFile %s already exist, Overwrite(Yes/No)?[Y]: " % VpdFileName)\r
choice = sys.stdin.readline()\r
if choice.strip().lower() not in ['y', 'yes', '']:\r
return\r
\r
## Import Modules\r
#\r
+from __future__ import print_function\r
from Common.GlobalData import *\r
from CommonDataClass.Exceptions import BadExpression\r
from CommonDataClass.Exceptions import WrnExpression\r
if input in 'qQ':\r
break\r
try:\r
- print ValueExpression(input)(True)\r
- print ValueExpression(input)(False)\r
+ print(ValueExpression(input)(True))\r
+ print(ValueExpression(input)(False))\r
except WrnExpression as Ex:\r
- print Ex.result\r
- print str(Ex)\r
+ print(Ex.result)\r
+ print(str(Ex))\r
except Exception as Ex:\r
- print str(Ex)\r
+ print(str(Ex))\r
\r
# # Import Modules\r
#\r
+from __future__ import print_function\r
from Common.GlobalData import *\r
from CommonDataClass.Exceptions import BadExpression\r
from CommonDataClass.Exceptions import WrnExpression\r
self.__clean__()\r
\r
def dump(self):\r
- print "----------------------"\r
+ print("----------------------")\r
rangelist = ""\r
for object in self.rangelist:\r
rangelist = rangelist + "[%d , %d]" % (object.start, object.end)\r
- print rangelist\r
+ print(rangelist)\r
\r
\r
class XOROperatorObject(object): \r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os\r
import EdkLogger\r
import DataType\r
if __name__ == '__main__':\r
pass\r
Target = TargetTxtDict(os.getenv("WORKSPACE"))\r
- print Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER]\r
- print Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET]\r
- print Target.TargetTxtDictionary\r
+ print(Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER])\r
+ print(Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET])\r
+ print(Target.TargetTxtDictionary)\r
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
#\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os\r
import re\r
import Common.EdkLogger as EdkLogger\r
except Exception as X:\r
EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData=str(X))\r
(out, error) = PopenObject.communicate()\r
- print out\r
+ print(out)\r
while PopenObject.returncode is None :\r
PopenObject.wait()\r
\r
# $ANTLR 3.0.1 C.g 2010-02-23 09:58:53\r
\r
+from __future__ import print_function\r
from antlr3 import *\r
from antlr3.compat import set, frozenset\r
\r
self.postfix_expression_stack = []\r
\r
def printTokenInfo(self, line, offset, tokenText):\r
- print str(line)+ ',' + str(offset) + ':' + str(tokenText)\r
- \r
+ print(str(line)+ ',' + str(offset) + ':' + str(tokenText))\r
+\r
def StorePredicateExpression(self, StartLine, StartOffset, EndLine, EndOffset, Text):\r
PredExp = CodeFragment.PredicateExpression(Text, (StartLine, StartOffset), (EndLine, EndOffset))\r
FileProfile.PredicateExpressionList.append(PredExp)\r
# Import Modules\r
#\r
\r
+from __future__ import print_function\r
import re\r
import Common.LongFilePathOs as os\r
import sys\r
\r
def PrintFragments(self):\r
\r
- print '################# ' + self.FileName + '#####################'\r
+ print('################# ' + self.FileName + '#####################')\r
\r
- print '/****************************************/'\r
- print '/*************** COMMENTS ***************/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/*************** COMMENTS ***************/')\r
+ print('/****************************************/')\r
for comment in FileProfile.CommentList:\r
- print str(comment.StartPos) + comment.Content\r
+ print(str(comment.StartPos) + comment.Content)\r
\r
- print '/****************************************/'\r
- print '/********* PREPROCESS DIRECTIVES ********/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/********* PREPROCESS DIRECTIVES ********/')\r
+ print('/****************************************/')\r
for pp in FileProfile.PPDirectiveList:\r
- print str(pp.StartPos) + pp.Content\r
+ print(str(pp.StartPos) + pp.Content)\r
\r
- print '/****************************************/'\r
- print '/********* VARIABLE DECLARATIONS ********/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/********* VARIABLE DECLARATIONS ********/')\r
+ print('/****************************************/')\r
for var in FileProfile.VariableDeclarationList:\r
- print str(var.StartPos) + var.Modifier + ' '+ var.Declarator\r
+ print(str(var.StartPos) + var.Modifier + ' '+ var.Declarator)\r
\r
- print '/****************************************/'\r
- print '/********* FUNCTION DEFINITIONS *********/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/********* FUNCTION DEFINITIONS *********/')\r
+ print('/****************************************/')\r
for func in FileProfile.FunctionDefinitionList:\r
- print str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos)\r
+ print(str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos))\r
\r
- print '/****************************************/'\r
- print '/************ ENUMERATIONS **************/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/************ ENUMERATIONS **************/')\r
+ print('/****************************************/')\r
for enum in FileProfile.EnumerationDefinitionList:\r
- print str(enum.StartPos) + enum.Content\r
+ print(str(enum.StartPos) + enum.Content)\r
\r
- print '/****************************************/'\r
- print '/*********** STRUCTS/UNIONS *************/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/*********** STRUCTS/UNIONS *************/')\r
+ print('/****************************************/')\r
for su in FileProfile.StructUnionDefinitionList:\r
- print str(su.StartPos) + su.Content\r
+ print(str(su.StartPos) + su.Content)\r
\r
- print '/****************************************/'\r
- print '/********* PREDICATE EXPRESSIONS ********/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/********* PREDICATE EXPRESSIONS ********/')\r
+ print('/****************************************/')\r
for predexp in FileProfile.PredicateExpressionList:\r
- print str(predexp.StartPos) + predexp.Content\r
+ print(str(predexp.StartPos) + predexp.Content)\r
\r
- print '/****************************************/' \r
- print '/************** TYPEDEFS ****************/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/************** TYPEDEFS ****************/')\r
+ print('/****************************************/')\r
for typedef in FileProfile.TypedefDefinitionList:\r
- print str(typedef.StartPos) + typedef.ToType\r
+ print(str(typedef.StartPos) + typedef.ToType)\r
\r
if __name__ == "__main__":\r
\r
collector = CodeFragmentCollector(sys.argv[1])\r
collector.PreprocessFile()\r
- print "For Test."\r
+ print("For Test.")\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os\r
import Common.EdkLogger as EdkLogger\r
from Common.DataType import *\r
self.__dict__[_ConfigFileToInternalTranslation[List[0]]] = List[1]\r
\r
def ShowMe(self):\r
- print self.Filename\r
+ print(self.Filename)\r
for Key in self.__dict__.keys():\r
- print Key, '=', self.__dict__[Key]\r
+ print(Key, '=', self.__dict__[Key])\r
\r
#\r
# test that our dict and out class still match in contents.\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
from Xml.XmlRoutines import *\r
import Common.LongFilePathOs as os\r
\r
#\r
if __name__ == '__main__':\r
El = ExceptionCheck('C:\\Hess\\Project\\BuildTool\\src\\Ecc\\exception.xml')\r
- print El.ExceptionList\r
+ print(El.ExceptionList)\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os\r
\r
import Common.EdkLogger as EdkLogger\r
try:\r
self.Cur.execute(SqlCommand)\r
except Exception as e:\r
- print "An error occurred when Drop a table:", e.args[0]\r
+ print("An error occurred when Drop a table:", e.args[0])\r
\r
## Get count\r
#\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import xml.dom.minidom\r
from Common.LongFilePathSupport import OpenLongFilePath as open\r
\r
XmlFile.close()\r
return Dom\r
except Exception as X:\r
- print X\r
+ print(X)\r
return ""\r
\r
# This acts like the main() function for the script, unless it is 'import'ed\r
A = CreateXmlElement('AAA', 'CCC', [['AAA', '111'], ['BBB', '222']], [['A', '1'], ['B', '2']])\r
B = CreateXmlElement('ZZZ', 'CCC', [['XXX', '111'], ['YYY', '222']], [['A', '1'], ['B', '2']])\r
C = CreateXmlList('DDD', 'EEE', [A, B], ['FFF', 'GGG'])\r
- print C.toprettyxml(indent = " ")\r
+ print(C.toprettyxml(indent = " "))\r
pass\r
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
#\r
\r
+from __future__ import print_function\r
import sys\r
import Common.LongFilePathOs as os\r
import re\r
for Result in ResultSet:\r
CommentSet.append(Result)\r
except:\r
- print 'Unrecognized chars in comment of file %s', FullFileName\r
+ print('Unrecognized chars in comment of file %s', FullFileName)\r
\r
\r
for Result in CommentSet:\r
for Result in ResultSet:\r
CommentSet.append(Result)\r
except:\r
- print 'Unrecognized chars in comment of file %s', FullFileName\r
+ print('Unrecognized chars in comment of file %s', FullFileName)\r
\r
# Func Decl check\r
SqlStatement = """ select Modifier, Name, StartLine, ID, Value\r
for Result in ResultSet:\r
CommentSet.append(Result)\r
except:\r
- print 'Unrecognized chars in comment of file %s', FullFileName\r
+ print('Unrecognized chars in comment of file %s', FullFileName)\r
\r
SqlStatement = """ select Modifier, Header, StartLine, ID, Name\r
from Function\r
try:\r
test_file = sys.argv[1]\r
except IndexError as v:\r
- print "Usage: %s filename" % sys.argv[0]\r
+ print("Usage: %s filename" % sys.argv[0])\r
sys.exit(1)\r
MsgList = CheckFuncHeaderDoxygenComments(test_file)\r
for Msg in MsgList:\r
- print Msg\r
- print 'Done!'\r
+ print(Msg)\r
+ print('Done!')\r
# $ANTLR 3.0.1 C.g 2010-02-23 09:58:53\r
\r
+from __future__ import print_function\r
from antlr3 import *\r
from antlr3.compat import set, frozenset\r
\r
self.postfix_expression_stack = []\r
\r
def printTokenInfo(self, line, offset, tokenText):\r
- print str(line)+ ',' + str(offset) + ':' + str(tokenText)\r
- \r
+ print(str(line)+ ',' + str(offset) + ':' + str(tokenText))\r
+\r
def StorePredicateExpression(self, StartLine, StartOffset, EndLine, EndOffset, Text):\r
PredExp = CodeFragment.PredicateExpression(Text, (StartLine, StartOffset), (EndLine, EndOffset))\r
FileProfile.PredicateExpressionList.append(PredExp)\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import re\r
import Common.LongFilePathOs as os\r
import sys\r
#\r
def PrintFragments(self):\r
\r
- print '################# ' + self.FileName + '#####################'\r
+ print('################# ' + self.FileName + '#####################')\r
\r
- print '/****************************************/'\r
- print '/*************** ASSIGNMENTS ***************/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/*************** ASSIGNMENTS ***************/')\r
+ print('/****************************************/')\r
for asign in FileProfile.AssignmentExpressionList:\r
- print str(asign.StartPos) + asign.Name + asign.Operator + asign.Value\r
+ print(str(asign.StartPos) + asign.Name + asign.Operator + asign.Value)\r
\r
- print '/****************************************/'\r
- print '/********* PREPROCESS DIRECTIVES ********/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/********* PREPROCESS DIRECTIVES ********/')\r
+ print('/****************************************/')\r
for pp in FileProfile.PPDirectiveList:\r
- print str(pp.StartPos) + pp.Content\r
+ print(str(pp.StartPos) + pp.Content)\r
\r
- print '/****************************************/'\r
- print '/********* VARIABLE DECLARATIONS ********/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/********* VARIABLE DECLARATIONS ********/')\r
+ print('/****************************************/')\r
for var in FileProfile.VariableDeclarationList:\r
- print str(var.StartPos) + var.Modifier + ' '+ var.Declarator\r
+ print(str(var.StartPos) + var.Modifier + ' '+ var.Declarator)\r
\r
- print '/****************************************/'\r
- print '/********* FUNCTION DEFINITIONS *********/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/********* FUNCTION DEFINITIONS *********/')\r
+ print('/****************************************/')\r
for func in FileProfile.FunctionDefinitionList:\r
- print str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos)\r
+ print(str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos))\r
\r
- print '/****************************************/'\r
- print '/************ ENUMERATIONS **************/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/************ ENUMERATIONS **************/')\r
+ print('/****************************************/')\r
for enum in FileProfile.EnumerationDefinitionList:\r
- print str(enum.StartPos) + enum.Content\r
+ print(str(enum.StartPos) + enum.Content)\r
\r
- print '/****************************************/'\r
- print '/*********** STRUCTS/UNIONS *************/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/*********** STRUCTS/UNIONS *************/')\r
+ print('/****************************************/')\r
for su in FileProfile.StructUnionDefinitionList:\r
- print str(su.StartPos) + su.Content\r
+ print(str(su.StartPos) + su.Content)\r
\r
- print '/****************************************/'\r
- print '/************** TYPEDEFS ****************/'\r
- print '/****************************************/'\r
+ print('/****************************************/')\r
+ print('/************** TYPEDEFS ****************/')\r
+ print('/****************************************/')\r
for typedef in FileProfile.TypedefDefinitionList:\r
- print str(typedef.StartPos) + typedef.ToType\r
+ print(str(typedef.StartPos) + typedef.ToType)\r
\r
##\r
#\r
#\r
if __name__ == "__main__":\r
\r
- print "For Test."\r
+ print("For Test.")\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os\r
import Common.EdkLogger as EdkLogger\r
from Common.DataType import *\r
Db.InitDatabase()\r
P = EdkInfParser(os.path.normpath("C:\Framework\Edk\Sample\Platform\Nt32\Dxe\PlatformBds\PlatformBds.inf"), Db, '', '')\r
for Inf in P.Sources:\r
- print Inf\r
+ print(Inf)\r
for Item in P.Macros:\r
- print Item, P.Macros[Item]\r
+ print(Item, P.Macros[Item])\r
\r
- Db.Close()
\ No newline at end of file
+ Db.Close()\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import sys\r
import Common.LongFilePathOs as os\r
import re\r
EdkLogger.SetLevel(EdkLogger.QUIET)\r
CollectSourceCodeDataIntoDB(sys.argv[1])\r
\r
- print 'Done!'\r
+ print('Done!')\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import re\r
\r
import Fd\r
try:\r
test_file = sys.argv[1]\r
except IndexError as v:\r
- print "Usage: %s filename" % sys.argv[0]\r
+ print("Usage: %s filename" % sys.argv[0])\r
sys.exit(1)\r
\r
parser = FdfParser(test_file)\r
parser.ParseFile()\r
parser.CycleReferenceCheck()\r
except Warning as X:\r
- print str(X)\r
+ print(str(X))\r
else:\r
- print "Success!"\r
+ print("Success!")\r
\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
from optparse import OptionParser\r
import sys\r
import Common.LongFilePathOs as os\r
ModuleDict = BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules\r
for Key in ModuleDict:\r
ModuleObj = BuildDb.BuildObject[Key, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
- print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType\r
+ print(ModuleObj.BaseName + ' ' + ModuleObj.ModuleType)\r
\r
def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj):\r
GuidXRefFileName = os.path.join(GenFdsGlobalVariable.FvDir, "Guid.xref")\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os\r
import sys\r
import subprocess\r
GenFdsGlobalVariable.InfLogger (out)\r
GenFdsGlobalVariable.InfLogger (error)\r
if PopenObject.returncode != 0:\r
- print "###", cmd\r
+ print("###", cmd)\r
EdkLogger.error("GenFds", COMMAND_FAILURE, errorMess)\r
\r
def VerboseLogger (msg):\r
#\r
\r
#====================================== External Libraries ========================================\r
+from __future__ import print_function\r
import optparse\r
import Common.LongFilePathOs as os\r
import re\r
(options, args) = parser.parse_args()\r
\r
if options.mapfile is None or options.efifile is None:\r
- print parser.get_usage()\r
+ print(parser.get_usage())\r
elif os.path.exists(options.mapfile) and os.path.exists(options.efifile):\r
list = parsePcdInfoFromMapFile(options.mapfile, options.efifile)\r
if list is not None:\r
else:\r
generatePcdTable(list, options.mapfile.replace('.map', '.BinaryPcdTable.txt'))\r
else:\r
- print 'Fail to generate Patch PCD Table based on map file and efi file'\r
+ print('Fail to generate Patch PCD Table based on map file and efi file')\r
else:\r
- print 'Fail to generate Patch PCD Table for fail to find map file or efi file!'\r
+ print('Fail to generate Patch PCD Table for fail to find map file or efi file!')\r
'''\r
Pkcs7Sign\r
'''\r
+from __future__ import print_function\r
\r
import os\r
import sys\r
try:\r
Process = subprocess.Popen('%s version' % (OpenSslCommand), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
except:\r
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'\r
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')\r
sys.exit(1)\r
\r
Version = Process.communicate()\r
if Process.returncode <> 0:\r
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'\r
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')\r
sys.exit(Process.returncode)\r
- print Version[0]\r
+ print(Version[0])\r
\r
#\r
# Read input file into a buffer and save input filename\r
#\r
OutputDir = os.path.dirname(args.OutputFile)\r
if not os.path.exists(OutputDir):\r
- print 'ERROR: The output path does not exist: %s' % OutputDir\r
+ print('ERROR: The output path does not exist: %s' % OutputDir)\r
sys.exit(1)\r
args.OutputFileName = args.OutputFile\r
\r
args.SignerPrivateCertFile = open(args.SignerPrivateCertFileName, 'rb')\r
args.SignerPrivateCertFile.close()\r
except:\r
- print 'ERROR: test signer private cert file %s missing' % (args.SignerPrivateCertFileName)\r
+ print('ERROR: test signer private cert file %s missing' % (args.SignerPrivateCertFileName))\r
sys.exit(1)\r
\r
#\r
args.OtherPublicCertFile = open(args.OtherPublicCertFileName, 'rb')\r
args.OtherPublicCertFile.close()\r
except:\r
- print 'ERROR: test other public cert file %s missing' % (args.OtherPublicCertFileName)\r
+ print('ERROR: test other public cert file %s missing' % (args.OtherPublicCertFileName))\r
sys.exit(1)\r
\r
format = "%dsQ" % len(args.InputFileBuffer)\r
args.TrustedPublicCertFile = open(args.TrustedPublicCertFileName, 'rb')\r
args.TrustedPublicCertFile.close()\r
except:\r
- print 'ERROR: test trusted public cert file %s missing' % (args.TrustedPublicCertFileName)\r
+ print('ERROR: test trusted public cert file %s missing' % (args.TrustedPublicCertFileName))\r
sys.exit(1)\r
\r
if not args.SignatureSizeStr:\r
- print "ERROR: please use the option --signature-size to specify the size of the signature data!"\r
+ print("ERROR: please use the option --signature-size to specify the size of the signature data!")\r
sys.exit(1)\r
else:\r
if args.SignatureSizeStr.upper().startswith('0X'):\r
else:\r
SignatureSize = (long)(args.SignatureSizeStr)\r
if SignatureSize < 0:\r
- print "ERROR: The value of option --signature-size can't be set to negative value!"\r
+ print("ERROR: The value of option --signature-size can't be set to negative value!")\r
sys.exit(1)\r
elif SignatureSize > len(args.InputFileBuffer):\r
- print "ERROR: The value of option --signature-size is exceed the size of the input file !"\r
+ print("ERROR: The value of option --signature-size is exceed the size of the input file !")\r
sys.exit(1)\r
\r
args.SignatureBuffer = args.InputFileBuffer[0:SignatureSize]\r
Process = subprocess.Popen('%s smime -verify -inform DER -content %s -CAfile %s' % (OpenSslCommand, args.OutputFileName, args.TrustedPublicCertFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
Process.communicate(input=args.SignatureBuffer)[0]\r
if Process.returncode <> 0:\r
- print 'ERROR: Verification failed'\r
+ print('ERROR: Verification failed')\r
os.remove (args.OutputFileName)\r
sys.exit(Process.returncode)\r
\r
'''\r
Rsa2048Sha256GenerateKeys\r
'''\r
+from __future__ import print_function\r
\r
import os\r
import sys\r
try:\r
Process = subprocess.Popen('%s version' % (OpenSslCommand), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
except: \r
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'\r
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')\r
sys.exit(1)\r
\r
Version = Process.communicate()\r
if Process.returncode <> 0:\r
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'\r
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')\r
sys.exit(Process.returncode)\r
- print Version[0]\r
+ print(Version[0])\r
\r
args.PemFileName = []\r
\r
Process = subprocess.Popen('%s genrsa -out %s 2048' % (OpenSslCommand, Item.name), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
Process.communicate()\r
if Process.returncode <> 0:\r
- print 'ERROR: RSA 2048 key generation failed'\r
+ print('ERROR: RSA 2048 key generation failed')\r
sys.exit(Process.returncode)\r
\r
#\r
Process = subprocess.Popen('%s rsa -in %s -modulus -noout' % (OpenSslCommand, Item), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
PublicKeyHexString = Process.communicate()[0].split('=')[1].strip()\r
if Process.returncode <> 0:\r
- print 'ERROR: Unable to extract public key from private key'\r
+ print('ERROR: Unable to extract public key from private key')\r
sys.exit(Process.returncode)\r
PublicKey = ''\r
for Index in range (0, len(PublicKeyHexString), 2):\r
Process.stdin.write (PublicKey)\r
PublicKeyHash = PublicKeyHash + Process.communicate()[0]\r
if Process.returncode <> 0:\r
- print 'ERROR: Unable to extract SHA 256 hash of public key'\r
+ print('ERROR: Unable to extract SHA 256 hash of public key')\r
sys.exit(Process.returncode)\r
\r
#\r
# If verbose is enabled display the public key in C structure format\r
#\r
if args.Verbose:\r
- print 'PublicKeySha256 = ' + PublicKeyHashC \r
+ print('PublicKeySha256 = ' + PublicKeyHashC)\r
'''\r
Rsa2048Sha256Sign\r
'''\r
+from __future__ import print_function\r
\r
import os\r
import sys\r
try:\r
Process = subprocess.Popen('%s version' % (OpenSslCommand), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
except: \r
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'\r
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')\r
sys.exit(1)\r
\r
Version = Process.communicate()\r
if Process.returncode <> 0:\r
- print 'ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH'\r
+ print('ERROR: Open SSL command not available. Please verify PATH or set OPENSSL_PATH')\r
sys.exit(Process.returncode)\r
- print Version[0]\r
+ print(Version[0])\r
\r
#\r
# Read input file into a buffer and save input filename\r
#\r
OutputDir = os.path.dirname(args.OutputFile)\r
if not os.path.exists(OutputDir):\r
- print 'ERROR: The output path does not exist: %s' % OutputDir\r
+ print('ERROR: The output path does not exist: %s' % OutputDir)\r
sys.exit(1)\r
args.OutputFileName = args.OutputFile\r
\r
args.PrivateKeyFile = open(args.PrivateKeyFileName, 'rb')\r
args.PrivateKeyFile.close()\r
except:\r
- print 'ERROR: test signing private key file %s missing' % (args.PrivateKeyFileName)\r
+ print('ERROR: test signing private key file %s missing' % (args.PrivateKeyFileName))\r
sys.exit(1)\r
\r
#\r
# Verify that the Hash Type matches the expected SHA256 type\r
#\r
if uuid.UUID(bytes_le = Header.HashType) <> EFI_HASH_ALGORITHM_SHA256_GUID:\r
- print 'ERROR: unsupport hash GUID'\r
+ print('ERROR: unsupport hash GUID')\r
sys.exit(1)\r
\r
#\r
# Verify the public key\r
#\r
if Header.PublicKey <> PublicKey:\r
- print 'ERROR: Public key in input file does not match public key from private key file'\r
+ print('ERROR: Public key in input file does not match public key from private key file')\r
sys.exit(1)\r
\r
FullInputFileBuffer = args.InputFileBuffer\r
Process = subprocess.Popen('%s dgst -sha256 -prverify "%s" -signature %s' % (OpenSslCommand, args.PrivateKeyFileName, args.OutputFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
Process.communicate(input=FullInputFileBuffer)\r
if Process.returncode <> 0:\r
- print 'ERROR: Verification failed'\r
+ print('ERROR: Verification failed')\r
os.remove (args.OutputFileName)\r
sys.exit(Process.returncode)\r
\r
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
#\r
\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os\r
import sys\r
import traceback\r
self.Arg = args[0]\r
self.FileName = os.path.normpath(os.path.join(self.WorkSpace, 'Conf', 'target.txt'))\r
if os.path.isfile(self.FileName) == False:\r
- print "%s does not exist." % self.FileName\r
+ print("%s does not exist." % self.FileName)\r
sys.exit(1)\r
self.TargetTxtDictionary = {\r
TAB_TAT_DEFINES_ACTIVE_PLATFORM : None,\r
errMsg = ''\r
for Key in self.TargetTxtDictionary:\r
if type(self.TargetTxtDictionary[Key]) == type([]):\r
- print "%-30s = %s" % (Key, ''.join(elem + ' ' for elem in self.TargetTxtDictionary[Key]))\r
+ print("%-30s = %s" % (Key, ''.join(elem + ' ' for elem in self.TargetTxtDictionary[Key])))\r
elif self.TargetTxtDictionary[Key] is None:\r
errMsg += " Missing %s configuration information, please use TargetTool to set value!" % Key + os.linesep \r
else:\r
- print "%-30s = %s" % (Key, self.TargetTxtDictionary[Key])\r
+ print("%-30s = %s" % (Key, self.TargetTxtDictionary[Key]))\r
\r
if errMsg != '':\r
- print os.linesep + 'Warning:' + os.linesep + errMsg\r
+ print(os.linesep + 'Warning:' + os.linesep + errMsg)\r
\r
def RWFile(self, CommentCharacter, KeySplitCharacter, Num):\r
try:\r
if Key not in existKeys:\r
existKeys.append(Key)\r
else:\r
- print "Warning: Found duplicate key item in original configuration files!"\r
+ print("Warning: Found duplicate key item in original configuration files!")\r
\r
if Num == 0:\r
Line = "%-30s = \n" % Key\r
fw.write(Line)\r
for key in self.TargetTxtDictionary:\r
if key not in existKeys:\r
- print "Warning: %s does not exist in original configuration file" % key\r
+ print("Warning: %s does not exist in original configuration file" % key)\r
Line = GetConfigureKeyValue(self, key)\r
if Line is None:\r
Line = "%-30s = " % key\r
EdkLogger.Initialize()\r
EdkLogger.SetLevel(EdkLogger.QUIET)\r
if os.getenv('WORKSPACE') is None:\r
- print "ERROR: WORKSPACE should be specified or edksetup script should be executed before run TargetTool"\r
+ print("ERROR: WORKSPACE should be specified or edksetup script should be executed before run TargetTool")\r
sys.exit(1)\r
\r
(opt, args) = MyOptionParser()\r
if len(args) != 1 or (args[0].lower() != 'print' and args[0].lower() != 'clean' and args[0].lower() != 'set'):\r
- print "The number of args isn't 1 or the value of args is invalid."\r
+ print("The number of args isn't 1 or the value of args is invalid.")\r
sys.exit(1)\r
if opt.NUM is not None and opt.NUM < 1:\r
- print "The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0."\r
+ print("The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0.")\r
sys.exit(1)\r
if opt.TARGET is not None and len(opt.TARGET) > 1:\r
for elem in opt.TARGET:\r
if elem == '0':\r
- print "0 will clear the TARGET setting in target.txt and can't combine with other value."\r
+ print("0 will clear the TARGET setting in target.txt and can't combine with other value.")\r
sys.exit(1)\r
if opt.TARGET_ARCH is not None and len(opt.TARGET_ARCH) > 1:\r
for elem in opt.TARGET_ARCH:\r
if elem == '0':\r
- print "0 will clear the TARGET_ARCH setting in target.txt and can't combine with other value."\r
+ print("0 will clear the TARGET_ARCH setting in target.txt and can't combine with other value.")\r
sys.exit(1)\r
\r
try:\r
'''\r
ExpressionValidate\r
'''\r
+from __future__ import print_function\r
\r
##\r
# Import Modules\r
\r
if __name__ == '__main__':\r
# print IsValidRangeExpr('LT 9')\r
- print _LogicalExpressionParser('gCrownBayTokenSpaceGuid.PcdPciDevice1BridgeAddressLE0').IsValidLogicalExpression()\r
+ print(_LogicalExpressionParser('gCrownBayTokenSpaceGuid.PcdPciDevice1BridgeAddressLE0').IsValidLogicalExpression())\r
\r
\r
\r
"""\r
Collect all defined strings in multiple uni files\r
"""\r
+from __future__ import print_function\r
\r
##\r
# Import Modules\r
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)\r
NewLines.append(Line)\r
else:\r
- print Line\r
+ print(Line)\r
EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)\r
\r
if StrName and not StrName.split()[1].startswith(u'STR_'):\r
# Show the instance itself\r
#\r
def ShowMe(self):\r
- print self.LanguageDef\r
+ print(self.LanguageDef)\r
#print self.OrderedStringList\r
for Item in self.OrderedStringList:\r
- print Item\r
+ print(Item)\r
for Member in self.OrderedStringList[Item]:\r
- print str(Member)\r
+ print(str(Member))\r
\r
#\r
# Read content from '!include' UNI file \r
'''\r
DecPomAlignment\r
'''\r
+from __future__ import print_function\r
\r
##\r
# Import Modules\r
# Print all members and their values of Package class\r
#\r
def ShowPackage(self):\r
- print '\nName =', self.GetName()\r
- print '\nBaseName =', self.GetBaseName()\r
- print '\nVersion =', self.GetVersion() \r
- print '\nGuid =', self.GetGuid()\r
+ print('\nName =', self.GetName())\r
+ print('\nBaseName =', self.GetBaseName())\r
+ print('\nVersion =', self.GetVersion())\r
+ print('\nGuid =', self.GetGuid())\r
\r
- print '\nStandardIncludes = %d ' \\r
- % len(self.GetStandardIncludeFileList()),\r
+ print('\nStandardIncludes = %d ' \\r
+ % len(self.GetStandardIncludeFileList()), end=' ')\r
for Item in self.GetStandardIncludeFileList():\r
- print Item.GetFilePath(), ' ', Item.GetSupArchList()\r
- print '\nPackageIncludes = %d \n' \\r
- % len(self.GetPackageIncludeFileList()),\r
+ print(Item.GetFilePath(), ' ', Item.GetSupArchList())\r
+ print('\nPackageIncludes = %d \n' \\r
+ % len(self.GetPackageIncludeFileList()), end=' ')\r
for Item in self.GetPackageIncludeFileList():\r
- print Item.GetFilePath(), ' ', Item.GetSupArchList()\r
+ print(Item.GetFilePath(), ' ', Item.GetSupArchList())\r
\r
- print '\nGuids =', self.GetGuidList()\r
+ print('\nGuids =', self.GetGuidList())\r
for Item in self.GetGuidList():\r
- print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()\r
- print '\nProtocols =', self.GetProtocolList()\r
+ print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList())\r
+ print('\nProtocols =', self.GetProtocolList())\r
for Item in self.GetProtocolList():\r
- print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()\r
- print '\nPpis =', self.GetPpiList()\r
+ print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList())\r
+ print('\nPpis =', self.GetPpiList())\r
for Item in self.GetPpiList():\r
- print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()\r
- print '\nLibraryClasses =', self.GetLibraryClassList()\r
+ print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList())\r
+ print('\nLibraryClasses =', self.GetLibraryClassList())\r
for Item in self.GetLibraryClassList():\r
- print Item.GetLibraryClass(), Item.GetRecommendedInstance(), \\r
- Item.GetSupArchList()\r
- print '\nPcds =', self.GetPcdList()\r
+ print(Item.GetLibraryClass(), Item.GetRecommendedInstance(), \\r
+ Item.GetSupArchList())\r
+ print('\nPcds =', self.GetPcdList())\r
for Item in self.GetPcdList():\r
- print 'CName=', Item.GetCName(), 'TokenSpaceGuidCName=', \\r
+ print('CName=', Item.GetCName(), 'TokenSpaceGuidCName=', \\r
Item.GetTokenSpaceGuidCName(), \\r
'DefaultValue=', Item.GetDefaultValue(), \\r
'ValidUsage=', Item.GetValidUsage(), \\r
'SupArchList', Item.GetSupArchList(), \\r
- 'Token=', Item.GetToken(), 'DatumType=', Item.GetDatumType()\r
+ 'Token=', Item.GetToken(), 'DatumType=', Item.GetDatumType())\r
\r
for Item in self.GetMiscFileList():\r
- print Item.GetName()\r
+ print(Item.GetName())\r
for FileObjectItem in Item.GetFileList():\r
- print FileObjectItem.GetURI()\r
- print '****************\n'\r
+ print(FileObjectItem.GetURI())\r
+ print('****************\n')\r
\r
## GenPcdDeclaration\r
#\r
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
+from __future__ import print_function\r
import os\r
import unittest\r
\r
# Close file\r
f.close()\r
except:\r
- print 'Can not create temporary file [%s]!' % Path\r
+ print('Can not create temporary file [%s]!' % Path)\r
exit(-1)\r
\r
# Call test function to test\r
unittest.FunctionTestCase(TestDecPcd).runTest()\r
unittest.FunctionTestCase(TestDecUserExtension).runTest()\r
\r
- print 'All tests passed...'\r
+ print('All tests passed...')\r
\r
\r
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
+from __future__ import print_function\r
import os\r
#import Object.Parser.InfObject as InfObject\r
from Object.Parser.InfCommonObject import CurrentLine\r
TempFile = open (FileName, "w") \r
TempFile.close()\r
except:\r
- print "File Create Error"\r
+ print("File Create Error")\r
CurrentLine = CurrentLine()\r
CurrentLine.SetFileName("Test")\r
CurrentLine.SetLineString(Item[0])\r
try:\r
InfBinariesInstance.SetBinary(Ver = Ver, ArchList = ArchList)\r
except:\r
- print "Test Failed!"\r
+ print("Test Failed!")\r
AllPassedFlag = False\r
\r
if AllPassedFlag :\r
- print 'All tests passed...'\r
+ print('All tests passed...')\r
else:\r
- print 'Some unit test failed!'\r
+ print('Some unit test failed!')\r
\r
# This class is used to retrieve information stored in database and convert them\r
# into PlatformBuildClassObject form for easier use for AutoGen.\r
#\r
+from __future__ import print_function\r
from Common.StringUtils import *\r
from Common.DataType import *\r
from Common.Misc import *\r
for (skuname,StoreName,PcdGuid,PcdName,PcdValue) in Str_Pcd_Values:\r
str_pcd_obj = S_pcd_set.get((PcdName, PcdGuid))\r
if str_pcd_obj is None:\r
- print PcdName, PcdGuid\r
+ print(PcdName, PcdGuid)\r
raise\r
if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],\r
self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %\r
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2]))\r
except:\r
- print "error"\r
+ print("error")\r
try:\r
Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])\r
except Exception:\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os\r
import re\r
import time\r
try:\r
self._ValueList[2] = '|'.join(ValList)\r
except Exception:\r
- print ValList\r
+ print(ValList)\r
\r
def __ProcessComponent(self):\r
self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros)\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import Common.LongFilePathOs as os\r
import re\r
import StringIO\r
toolsFile = os.path.join(FvDir, 'GuidedSectionTools.txt')\r
toolsFile = open(toolsFile, 'wt')\r
for guidedSectionTool in guidAttribs:\r
- print >> toolsFile, ' '.join(guidedSectionTool)\r
+ print(' '.join(guidedSectionTool), file=toolsFile)\r
toolsFile.close()\r
\r
## Returns the full path of the tool.\r
+from __future__ import print_function\r
## @file\r
# Utility functions and classes for BaseTools unit tests\r
#\r
os.remove(path)\r
\r
def DisplayBinaryData(self, description, data):\r
- print description, '(base64 encoded):'\r
+ print(description, '(base64 encoded):')\r
b64data = base64.b64encode(data)\r
- print b64data\r
+ print(b64data)\r
\r
def DisplayFile(self, fileName):\r
sys.stdout.write(self.ReadTmpFile(fileName))\r
##\r
# Import Modules\r
#\r
+from __future__ import print_function\r
import os\r
import random\r
import sys\r
finish = self.ReadTmpFile('output2')\r
startEqualsFinish = start == finish\r
if not startEqualsFinish:\r
- print\r
- print 'Original data did not match decompress(compress(data))'\r
+ print()\r
+ print('Original data did not match decompress(compress(data))')\r
self.DisplayBinaryData('original data', start)\r
self.DisplayBinaryData('after compression', self.ReadTmpFile('output1'))\r
self.DisplayBinaryData('after decomression', finish)\r
#
+from __future__ import print_function\r
from optparse import OptionParser
import os
import shutil
#
# This script (and edk2 BaseTools) require Python 2.5 or newer
#
- print 'Python version 2.5 or later is required.'
+ print('Python version 2.5 or later is required.')\r
sys.exit(-1)
#
if not self.options.skip_gcc:
building.append('gcc')
if len(building) == 0:
- print "Nothing will be built!"
- print
- print "Please try using --help and then change the configuration."
+ print("Nothing will be built!")\r
+ print()\r
+ print("Please try using --help and then change the configuration.")\r
return False
- print "Current directory:"
- print " ", self.base_dir
- print "Sources download/extraction:", self.Relative(self.src_dir)
- print "Build directory :", self.Relative(self.build_dir)
- print "Prefix (install) directory :", self.Relative(self.prefix)
- print "Create symlinks directory :", self.Relative(self.symlinks)
- print "Building :", ', '.join(building)
- print
+ print("Current directory:")\r
+ print(" ", self.base_dir)\r
+ print("Sources download/extraction:", self.Relative(self.src_dir))\r
+ print("Build directory :", self.Relative(self.build_dir))\r
+ print("Prefix (install) directory :", self.Relative(self.prefix))\r
+ print("Create symlinks directory :", self.Relative(self.symlinks))\r
+ print("Building :", ', '.join(building))\r
+ print()\r
answer = raw_input("Is this configuration ok? (default = no): ")
if (answer.lower() not in ('y', 'yes')):
- print
- print "Please try using --help and then change the configuration."
+ print()\r
+ print("Please try using --help and then change the configuration.")\r
return False
if self.arch.lower() == 'ipf':
- print
- print 'Please note that the IPF compiler built by this script has'
- print 'not yet been validated!'
- print
+ print()\r
+ print('Please note that the IPF compiler built by this script has')\r
+ print('not yet been validated!')\r
+ print()\r
answer = raw_input("Are you sure you want to build it? (default = no): ")
if (answer.lower() not in ('y', 'yes')):
- print
- print "Please try using --help and then change the configuration."
+ print()\r
+ print("Please try using --help and then change the configuration.")\r
return False
- print
+ print()\r
return True
def Relative(self, path):
wDots = (100 * received * blockSize) / fileSize / 10
if wDots > self.dots:
for i in range(wDots - self.dots):
- print '.',
+ print('.', end=' ')\r
sys.stdout.flush()
self.dots += 1
self.dots = 0
local_file = os.path.join(self.config.src_dir, fdata['filename'])
url = fdata['url']
- print 'Downloading %s:' % fname, url
+ print('Downloading %s:' % fname, url)\r
if retries > 0:
- print '(retry)',
+ print('(retry)', end=' ')\r
sys.stdout.flush()
completed = False
if os.path.exists(local_file):
md5_pass = self.checkHash(fdata)
if md5_pass:
- print '[md5 match]',
+ print('[md5 match]', end=' ')\r
else:
- print '[md5 mismatch]',
+ print('[md5 mismatch]', end=' ')\r
sys.stdout.flush()
completed = md5_pass
if not completed and os.path.exists(local_file):
md5_pass = self.checkHash(fdata)
if md5_pass:
- print '[md5 match]',
+ print('[md5 match]', end=' ')\r
else:
- print '[md5 mismatch]',
+ print('[md5 mismatch]', end=' ')\r
sys.stdout.flush()
completed = md5_pass
if completed:
- print '[done]'
+ print('[done]')\r
break
else:
- print '[failed]'
- print ' Tried to retrieve', url
- print ' to', local_file
- print 'Possible fixes:'
- print '* If you are behind a web-proxy, try setting the',
- print 'http_proxy environment variable'
- print '* You can try to download this file separately',
- print 'and rerun this script'
+ print('[failed]')\r
+ print(' Tried to retrieve', url)\r
+ print(' to', local_file)\r
+ print('Possible fixes:')\r
+ print('* If you are behind a web-proxy, try setting the', end=' ')\r
+ print('http_proxy environment variable')\r
+ print('* You can try to download this file separately', end=' ')\r
+ print('and rerun this script')\r
raise Exception()
except KeyboardInterrupt:
- print '[KeyboardInterrupt]'
+ print('[KeyboardInterrupt]')\r
return False
except Exception as e:\r
- print e
+ print(e)\r
if not completed: return False
extractedMd5 = open(extracted).read()
if extractedMd5 != moduleMd5:
- print 'Extracting %s:' % self.config.Relative(local_file)
+ print('Extracting %s:' % self.config.Relative(local_file))\r
tar = tarfile.open(local_file)
tar.extractall(extractDst)
open(extracted, 'w').write(moduleMd5)
os.chdir(base_dir)
- print '%s module is now built and installed' % module
+ print('%s module is now built and installed' % module)\r
def RunCommand(self, cmd, module, stage, skipable=False):
if skipable:
stderr=subprocess.STDOUT
)
- print '%s [%s] ...' % (module, stage),
+ print('%s [%s] ...' % (module, stage), end=' ')\r
sys.stdout.flush()
p = popen(cmd)
output = p.stdout.read()
p.wait()
if p.returncode != 0:
- print '[failed!]'
+ print('[failed!]')\r
logFile = os.path.join(self.config.build_dir, 'log.txt')
f = open(logFile, "w")
f.write(output)
raise Exception, 'Failed to %s %s\n' % (stage, module) + \
'See output log at %s' % self.config.Relative(logFile)
else:
- print '[done]'
+ print('[done]')\r
if skipable:
self.MarkBuildStepComplete('%s.%s' % (module, stage))
linkdst = os.path.join(links_dir, link)
if not os.path.lexists(linkdst):
if not startPrinted:
- print 'Making symlinks in %s:' % self.config.Relative(links_dir),
+ print('Making symlinks in %s:' % self.config.Relative(links_dir), end=' ')\r
startPrinted = True
- print link,
+ print(link, end=' ')\r
os.symlink(src, linkdst)
if startPrinted:
- print '[done]'
+ print('[done]')\r
class App:
"""class App
sources = SourceFiles(config)
result = sources.GetAll()
if result:
- print 'All files have been downloaded & verified'
+ print('All files have been downloaded & verified')\r
else:
- print 'An error occured while downloading a file'
+ print('An error occured while downloading a file')\r
return
Extracter(sources, config).ExtractAll()