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....@intel.com>
Cc: Liming Gao <liming....@intel.com>
Signed-off-by: Gary Lin <g...@suse.com>
---
 BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py                              
  |  3 +-
 BaseTools/Scripts/BinToPcd.py                                                  
  |  1 +
 BaseTools/Scripts/FormatDosFiles.py                                            
  |  1 +
 BaseTools/Scripts/MemoryProfileSymbolGen.py                                    
  | 13 +--
 BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py                       
  | 47 +++++-----
 BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py 
  |  3 +-
 
BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py
 | 29 +++---
 BaseTools/Scripts/SmiHandlerProfileSymbolGen.py                                
  | 19 ++--
 BaseTools/Source/Python/AutoGen/AutoGen.py                                     
  |  5 +-
 BaseTools/Source/Python/AutoGen/BuildEngine.py                                 
  | 31 +++---
 BaseTools/Source/Python/AutoGen/UniClassObject.py                              
  |  7 +-
 BaseTools/Source/Python/BPDG/BPDG.py                                           
  |  3 +-
 BaseTools/Source/Python/Common/Expression.py                                   
  | 11 ++-
 BaseTools/Source/Python/Common/RangeExpression.py                              
  |  5 +-
 BaseTools/Source/Python/Common/TargetTxtClassObject.py                         
  |  7 +-
 BaseTools/Source/Python/Common/VpdInfoFile.py                                  
  |  3 +-
 BaseTools/Source/Python/Ecc/CParser.py                                         
  |  3 +-
 BaseTools/Source/Python/Ecc/CodeFragmentCollector.py                           
  | 69 +++++++-------
 BaseTools/Source/Python/Ecc/Configuration.py                                   
  |  5 +-
 BaseTools/Source/Python/Ecc/Exception.py                                       
  |  3 +-
 BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py                 
  |  3 +-
 BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py                                 
  |  5 +-
 BaseTools/Source/Python/Ecc/c.py                                               
  | 13 +--
 BaseTools/Source/Python/Eot/CParser.py                                         
  |  3 +-
 BaseTools/Source/Python/Eot/CodeFragmentCollector.py                           
  | 61 ++++++------
 BaseTools/Source/Python/Eot/InfParserLite.py                                   
  |  7 +-
 BaseTools/Source/Python/Eot/c.py                                               
  |  3 +-
 BaseTools/Source/Python/GenFds/FdfParser.py                                    
  |  7 +-
 BaseTools/Source/Python/GenFds/GenFds.py                                       
  |  3 +-
 BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py                         
  |  3 +-
 BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py                   
  |  7 +-
 BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py                                 
  | 23 ++---
 BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py         
  | 15 +--
 BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py                 
  | 17 ++--
 BaseTools/Source/Python/TargetTool/TargetTool.py                               
  | 23 ++---
 BaseTools/Source/Python/UPT/Library/ExpressionValidate.py                      
  |  3 +-
 BaseTools/Source/Python/UPT/Library/UniClassObject.py                          
  |  9 +-
 BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py                      
  | 51 +++++-----
 BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py                          
  |  5 +-
 BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py                   
  |  9 +-
 BaseTools/Source/Python/Workspace/DscBuildData.py                              
  |  5 +-
 BaseTools/Source/Python/Workspace/MetaFileParser.py                            
  |  3 +-
 BaseTools/Source/Python/build/build.py                                         
  |  3 +-
 BaseTools/Tests/TestTools.py                                                   
  |  5 +-
 BaseTools/Tests/TianoCompress.py                                               
  |  5 +-
 BaseTools/gcc/mingw-gcc-build.py                                               
  | 99 ++++++++++----------
 46 files changed, 352 insertions(+), 306 deletions(-)

diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py 
b/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
index 69fd2d54413e..dd66c7111ac0 100755
--- a/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
@@ -23,6 +23,7 @@
 #
 # ExceptionList if a tool takes an argument with a / add it to the exception 
list
 #
+from __future__ import print_function
 import sys
 import os
 import subprocess
@@ -86,7 +87,7 @@ if __name__ == "__main__":
      ret = main(sys.argv[2:])
 
   except:
-    print "exiting: exception from " + sys.argv[0]
+    print("exiting: exception from " + sys.argv[0])
     ret = 2
 
   sys.exit(ret)
diff --git a/BaseTools/Scripts/BinToPcd.py b/BaseTools/Scripts/BinToPcd.py
index b907d3e5e000..10b5043325cc 100644
--- a/BaseTools/Scripts/BinToPcd.py
+++ b/BaseTools/Scripts/BinToPcd.py
@@ -14,6 +14,7 @@
 '''
 BinToPcd
 '''
+from __future__ import print_function
 
 import sys
 import argparse
diff --git a/BaseTools/Scripts/FormatDosFiles.py 
b/BaseTools/Scripts/FormatDosFiles.py
index 2f2d4d532c76..3b16af5a4413 100644
--- a/BaseTools/Scripts/FormatDosFiles.py
+++ b/BaseTools/Scripts/FormatDosFiles.py
@@ -16,6 +16,7 @@
 #
 # Import Modules
 #
+from __future__ import print_function
 import argparse
 import os
 import os.path
diff --git a/BaseTools/Scripts/MemoryProfileSymbolGen.py 
b/BaseTools/Scripts/MemoryProfileSymbolGen.py
index 5709ad4641cb..0a41f9d83271 100644
--- a/BaseTools/Scripts/MemoryProfileSymbolGen.py
+++ b/BaseTools/Scripts/MemoryProfileSymbolGen.py
@@ -14,6 +14,7 @@
 #
 ##
 
+from __future__ import print_function
 import os
 import re
 import sys
@@ -58,10 +59,10 @@ class Symbols:
         try:
             nmCommand = "nm"
             nmLineOption = "-l"
-            print "parsing (debug) - " + pdbName
+            print("parsing (debug) - " + pdbName)
             os.system ('%s %s %s > nmDump.line.log' % (nmCommand, 
nmLineOption, pdbName))
         except :
-            print 'ERROR: nm command not available.  Please verify PATH'
+            print('ERROR: nm command not available.  Please verify PATH')
             return
 
         #
@@ -111,11 +112,11 @@ class Symbols:
             DIA2DumpCommand = "Dia2Dump.exe"
             #DIA2SymbolOption = "-p"
             DIA2LinesOption = "-l"
-            print "parsing (pdb) - " + pdbName
+            print("parsing (pdb) - " + pdbName)
             #os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpCommand, 
DIA2SymbolOption, pdbName))
             os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, 
DIA2LinesOption, pdbName))
         except :
-            print 'ERROR: DIA2Dump command not available.  Please verify PATH'
+            print('ERROR: DIA2Dump command not available.  Please verify PATH')
             return
 
         #
@@ -254,12 +255,12 @@ def main():
     try :
         file = open(Options.inputfilename)
     except Exception:
-        print "fail to open " + Options.inputfilename
+        print("fail to open " + Options.inputfilename)
         return 1
     try :
         newfile = open(Options.outputfilename, "w")
     except Exception:
-        print "fail to open " + Options.outputfilename
+        print("fail to open " + Options.outputfilename)
         return 1
 
     try:
diff --git a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py 
b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
index 557ffa4505e4..4deeee01a5e8 100644
--- a/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
+++ b/BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
@@ -12,6 +12,7 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
+from __future__ import print_function
 import os, sys, logging, traceback, subprocess
 from optparse import OptionParser
 
@@ -62,7 +63,7 @@ def parseCmdArgs():
     default = "C:\\Program Files\\doxygen\\bin\\doxygen.exe"
     if options.DoxygenPath is None:
         if os.path.exists(default):
-            print "Warning: Assume doxygen tool is installed at %s. If not, 
please specify via -x" % default
+            print("Warning: Assume doxygen tool is installed at %s. If not, 
please specify via -x" % default)
             options.DoxygenPath = default
         else:
             errors.append('- Please specify the path of doxygen tool 
installation via option -x! or install it in default path %s' % default)
@@ -80,7 +81,7 @@ def parseCmdArgs():
         if options.PackagePath is not None and 
os.path.exists(options.PackagePath):
             dirpath = os.path.dirname(options.PackagePath)
             default = os.path.join (dirpath, "Document")
-            print 'Warning: Assume document output at %s. If not, please 
specify via option -o' % default
+            print('Warning: Assume document output at %s. If not, please 
specify via option -o' % default)
             options.OutputPath = default
             if not os.path.exists(default):
                 try:
@@ -92,21 +93,21 @@ def parseCmdArgs():
 
     if options.Arch is None:
         options.Arch = 'ALL'
-        print "Warning: Assume arch is \"ALL\". If not, specify via -a"
+        print("Warning: Assume arch is \"ALL\". If not, specify via -a")
 
     if options.DocumentMode is None:
         options.DocumentMode = "HTML"
-        print "Warning: Assume document mode is \"HTML\". If not, specify via 
-m"
+        print("Warning: Assume document mode is \"HTML\". If not, specify via 
-m")
 
     if options.IncludeOnly is None:
         options.IncludeOnly = False
-        print "Warning: Assume generate package document for all package\'s 
source including publich interfaces and implementation libraries and modules."
+        print("Warning: Assume generate package document for all package\'s 
source including publich interfaces and implementation libraries and modules.")
 
     if options.DocumentMode.lower() == 'chm':
         default = "C:\\Program Files\\HTML Help Workshop\\hhc.exe"
         if options.HtmlWorkshopPath is None:
             if os.path.exists(default):
-                print 'Warning: Assume the installation path of Microsoft HTML 
Workshop is %s. If not, specify via option -c.' % default
+                print('Warning: Assume the installation path of Microsoft HTML 
Workshop is %s. If not, specify via option -c.' % default)
                 options.HtmlWorkshopPath = default
             else:
                 errors.append('- Please specify the installation path of 
Microsoft HTML Workshop via option -c!')
@@ -114,7 +115,7 @@ def parseCmdArgs():
             errors.append('- The installation path of Microsoft HTML Workshop 
%s does not exists. ' % options.HtmlWorkshopPath)
 
     if len(errors) != 0:
-        print '\n'
+        print('\n')
         parser.error('Fail to start due to following reasons: \n%s' 
%'\n'.join(errors))
     return (options.WorkspacePath, options.PackagePath, options.DoxygenPath, 
options.OutputPath,
             options.Arch, options.DocumentMode, options.IncludeOnly, 
options.HtmlWorkshopPath)
@@ -130,21 +131,21 @@ def createPackageObject(wsPath, pkgPath):
     return pkgObj
 
 def callbackLogMessage(msg, level):
-    print msg.strip()
+    print(msg.strip())
 
 def callbackCreateDoxygenProcess(doxPath, configPath):
     if sys.platform == 'win32':
         cmd = '"%s" %s' % (doxPath, configPath)
     else:
         cmd = '%s %s' % (doxPath, configPath)
-    print cmd
+    print(cmd)
     subprocess.call(cmd, shell=True)
 
 
 def DocumentFixup(outPath, arch):
     # find BASE_LIBRARY_JUMP_BUFFER structure reference page
 
-    print '\n    >>> Start fixup document \n'
+    print('\n    >>> Start fixup document \n')
 
     for root, dirs, files in os.walk(outPath):
         for dir in dirs:
@@ -172,10 +173,10 @@ def DocumentFixup(outPath, arch):
             if text.find('MdePkg/Include/Library/UefiApplicationEntryPoint.h 
File Reference') != -1:
                 FixPageUefiApplicationEntryPoint(fullpath, text)
 
-    print '    >>> Finish all document fixing up! \n'
+    print('    >>> Finish all document fixing up! \n')
 
 def FixPageBaseLib(path, text):
-    print '    >>> Fixup BaseLib file page at file %s \n' % path
+    print('    >>> Fixup BaseLib file page at file %s \n' % path)
     lines = text.split('\n')
     lastBaseJumpIndex = -1
     lastIdtGateDescriptor = -1
@@ -211,10 +212,10 @@ def FixPageBaseLib(path, text):
     except:
         logging.getLogger().error("     <<< Fail to fixup file %s\n" % path)
         return
-    print "    <<< Finish to fixup file %s\n" % path
+    print("    <<< Finish to fixup file %s\n" % path)
 
 def FixPageIA32_IDT_GATE_DESCRIPTOR(path, text):
-    print '    >>> Fixup structure reference IA32_IDT_GATE_DESCRIPTOR at file 
%s \n' % path
+    print('    >>> Fixup structure reference IA32_IDT_GATE_DESCRIPTOR at file 
%s \n' % path)
     lines = text.split('\n')
     for index in range(len(lines) - 1, -1, -1):
         line = lines[index].strip()
@@ -229,10 +230,10 @@ def FixPageIA32_IDT_GATE_DESCRIPTOR(path, text):
     except:
         logging.getLogger().error("     <<< Fail to fixup file %s\n" % path)
         return
-    print "    <<< Finish to fixup file %s\n" % path
+    print("    <<< Finish to fixup file %s\n" % path)
 
 def FixPageBASE_LIBRARY_JUMP_BUFFER(path, text):
-    print '    >>> Fixup structure reference BASE_LIBRARY_JUMP_BUFFER at file 
%s \n' % path
+    print('    >>> Fixup structure reference BASE_LIBRARY_JUMP_BUFFER at file 
%s \n' % path)
     lines = text.split('\n')
     bInDetail = True
     bNeedRemove = False
@@ -266,10 +267,10 @@ def FixPageBASE_LIBRARY_JUMP_BUFFER(path, text):
     except:
         logging.getLogger().error("     <<< Fail to fixup file %s" % path)
         return
-    print "    <<< Finish to fixup file %s\n" % path
+    print("    <<< Finish to fixup file %s\n" % path)
 
 def FixPageUefiDriverEntryPoint(path, text):
-    print '    >>> Fixup file reference 
MdePkg/Include/Library/UefiDriverEntryPoint.h at file %s \n' % path
+    print('    >>> Fixup file reference 
MdePkg/Include/Library/UefiDriverEntryPoint.h at file %s \n' % path)
     lines = text.split('\n')
     bInModuleEntry = False
     bInEfiMain     = False
@@ -318,11 +319,11 @@ def FixPageUefiDriverEntryPoint(path, text):
     except:
         logging.getLogger().error("     <<< Fail to fixup file %s" % path)
         return
-    print "    <<< Finish to fixup file %s\n" % path
+    print("    <<< Finish to fixup file %s\n" % path)
 
 
 def FixPageUefiApplicationEntryPoint(path, text):
-    print '    >>> Fixup file reference 
MdePkg/Include/Library/UefiApplicationEntryPoint.h at file %s \n' % path
+    print('    >>> Fixup file reference 
MdePkg/Include/Library/UefiApplicationEntryPoint.h at file %s \n' % path)
     lines = text.split('\n')
     bInModuleEntry = False
     bInEfiMain     = False
@@ -371,7 +372,7 @@ def FixPageUefiApplicationEntryPoint(path, text):
     except:
         logging.getLogger().error("     <<< Fail to fixup file %s" % path)
         return
-    print "    <<< Finish to fixup file %s\n" % path
+    print("    <<< Finish to fixup file %s\n" % path)
 
 if __name__ == '__main__':
     wspath, pkgpath, doxpath, outpath, archtag, docmode, isinc, hwpath = 
parseCmdArgs()
@@ -424,6 +425,6 @@ if __name__ == '__main__':
         else:
             cmd = '%s %s' % (hwpath, indexpath)
         subprocess.call(cmd)
-        print '\nFinish to generate package document! Please open %s for 
review' % os.path.join(outpath, 'html', 'index.chm')
+        print('\nFinish to generate package document! Please open %s for 
review' % os.path.join(outpath, 'html', 'index.chm'))
     else:
-        print '\nFinish to generate package document! Please open %s for 
review' % os.path.join(outpath, 'html', 'index.html')
+        print('\nFinish to generate package document! Please open %s for 
review' % os.path.join(outpath, 'html', 'index.html'))
diff --git 
a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
 
b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
index a177590af597..fe2ba1d8a842 100644
--- 
a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
+++ 
b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
@@ -11,6 +11,7 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
+from __future__ import print_function
 import os
 
 from message import *
@@ -446,4 +447,4 @@ if __name__== '__main__':
     p.AddPage(Page('PCD', 'pcds'))
 
     df.Generate()
-    print df
+    print(df)
diff --git 
a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py
 
b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py
index 9db16a63c07a..290287b817e7 100644
--- 
a/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py
+++ 
b/BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py
@@ -11,6 +11,7 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
+from __future__ import print_function
 import array
 import uuid
 import re
@@ -250,12 +251,12 @@ class EfiFirmwareVolumeHeader(BinaryItem):
         return list2int(self._arr.tolist()[48:50])
 
     def Dump(self):
-        print 'Signature: %s' % self.GetSigunature()
-        print 'Attribute: 0x%X' % self.GetAttribute()
-        print 'Header Length: 0x%X' % self.GetHeaderLength()
-        print 'File system Guid: ', self.GetFileSystemGuid()
-        print 'Revision: 0x%X' % self.GetRevision()
-        print 'FvLength: 0x%X' % self.GetFvLength()
+        print('Signature: %s' % self.GetSigunature())
+        print('Attribute: 0x%X' % self.GetAttribute())
+        print('Header Length: 0x%X' % self.GetHeaderLength())
+        print('File system Guid: ', self.GetFileSystemGuid())
+        print('Revision: 0x%X' % self.GetRevision())
+        print('FvLength: 0x%X' % self.GetFvLength())
 
     def GetFileSystemGuid(self):
         list = self._arr.tolist()
@@ -348,7 +349,7 @@ class EfiFfs(object):
                 line.append('0x%X' % int(item))
                 count += 1
             else:
-                print ' '.join(line)
+                print(' '.join(line))
                 count = 0
                 line = []
                 line.append('0x%X' % int(item))
@@ -445,11 +446,11 @@ class EfiFfsHeader(BinaryItem):
         return 'Unknown Ffs State'
 
     def Dump(self):
-        print "FFS name: ", self.GetNameGuid()
-        print "FFS type: ", self.GetType()
-        print "FFS attr: 0x%X" % self.GetAttributes()
-        print "FFS size: 0x%X" % self.GetFfsSize()
-        print "FFS state: 0x%X" % self.GetState()
+        print("FFS name: ", self.GetNameGuid())
+        print("FFS type: ", self.GetType())
+        print("FFS attr: 0x%X" % self.GetAttributes())
+        print("FFS size: 0x%X" % self.GetFfsSize())
+        print("FFS state: 0x%X" % self.GetState())
 
     def GetRawData(self):
         return self._arr.tolist()
@@ -528,8 +529,8 @@ class EfiSectionHeader(BinaryItem):
         return self.section_type_map[type]
 
     def Dump(self):
-        print 'size = 0x%X' % self.GetSectionSize()
-        print 'type = 0x%X' % self.GetType()
+        print('size = 0x%X' % self.GetSectionSize())
+        print('type = 0x%X' % self.GetType())
 
 
 
diff --git a/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py 
b/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py
index 26c092410386..8ad5d471d052 100644
--- a/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py
+++ b/BaseTools/Scripts/SmiHandlerProfileSymbolGen.py
@@ -14,6 +14,7 @@
 #
 ##
 
+from __future__ import print_function
 import os
 import re
 import sys
@@ -61,10 +62,10 @@ class Symbols:
         try:
             nmCommand = "nm"
             nmLineOption = "-l"
-            print "parsing (debug) - " + pdbName
+            print("parsing (debug) - " + pdbName)
             os.system ('%s %s %s > nmDump.line.log' % (nmCommand, 
nmLineOption, pdbName))
         except :
-            print 'ERROR: nm command not available.  Please verify PATH'
+            print('ERROR: nm command not available.  Please verify PATH')
             return
 
         #
@@ -103,11 +104,11 @@ class Symbols:
             DIA2DumpCommand = "Dia2Dump.exe"
             #DIA2SymbolOption = "-p"
             DIA2LinesOption = "-l"
-            print "parsing (pdb) - " + pdbName
+            print("parsing (pdb) - " + pdbName)
             #os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpCommand, 
DIA2SymbolOption, pdbName))
             os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, 
DIA2LinesOption, pdbName))
         except :
-            print 'ERROR: DIA2Dump command not available.  Please verify PATH'
+            print('ERROR: DIA2Dump command not available.  Please verify PATH')
             return
 
         #
@@ -235,14 +236,14 @@ def main():
     try :
         DOMTree = xml.dom.minidom.parse(Options.inputfilename)
     except Exception:
-        print "fail to open input " + Options.inputfilename
+        print("fail to open input " + Options.inputfilename)
         return 1
 
     if Options.guidreffilename is not None:
         try :
             guidreffile = open(Options.guidreffilename)
         except Exception:
-            print "fail to open guidref" + Options.guidreffilename
+            print("fail to open guidref" + Options.guidreffilename)
             return 1
         genGuidString(guidreffile)
         guidreffile.close()
@@ -277,7 +278,7 @@ def main():
 
                     Handler = smiHandler.getElementsByTagName("Handler")
                     RVA = Handler[0].getElementsByTagName("RVA")
-                    print "    Handler RVA: %s" % RVA[0].childNodes[0].data
+                    print("    Handler RVA: %s" % RVA[0].childNodes[0].data)
 
                     if (len(RVA)) >= 1:
                         rvaName = RVA[0].childNodes[0].data
@@ -289,7 +290,7 @@ def main():
 
                     Caller = smiHandler.getElementsByTagName("Caller")
                     RVA = Caller[0].getElementsByTagName("RVA")
-                    print "    Caller RVA: %s" % RVA[0].childNodes[0].data
+                    print("    Caller RVA: %s" % RVA[0].childNodes[0].data)
 
                     if (len(RVA)) >= 1:
                         rvaName = RVA[0].childNodes[0].data
@@ -302,7 +303,7 @@ def main():
     try :
         newfile = open(Options.outputfilename, "w")
     except Exception:
-        print "fail to open output" + Options.outputfilename
+        print("fail to open output" + Options.outputfilename)
         return 1
 
     newfile.write(DOMTree.toprettyxml(indent = "\t", newl = "\n", encoding = 
"utf-8"))
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 72d801df8fd5..e268c4c0a1cf 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -15,6 +15,7 @@
 
 ## Import Modules
 #
+from __future__ import print_function
 import Common.LongFilePathOs as os
 import re
 import os.path as path
@@ -688,7 +689,7 @@ class WorkspaceAutoGen(AutoGen):
             os.makedirs(self.BuildDir)
         with open(os.path.join(self.BuildDir, 'AutoGen'), 'w+') as file:
             for f in AllWorkSpaceMetaFiles:
-                print >> file, f
+                print(f, file=file)
         return True
 
     def _GenPkgLevelHash(self, Pkg):
@@ -4362,7 +4363,7 @@ class ModuleAutoGen(AutoGen):
             os.remove (self.GetTimeStampPath())
         with open(self.GetTimeStampPath(), 'w+') as file:
             for f in FileSet:
-                print >> file, f
+                print(f, file=file)
 
     Module          = property(_GetModule)
     Name            = property(_GetBaseName)
diff --git a/BaseTools/Source/Python/AutoGen/BuildEngine.py 
b/BaseTools/Source/Python/AutoGen/BuildEngine.py
index ad1919442e6e..d4daa3093761 100644
--- a/BaseTools/Source/Python/AutoGen/BuildEngine.py
+++ b/BaseTools/Source/Python/AutoGen/BuildEngine.py
@@ -14,6 +14,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import Common.LongFilePathOs as os
 import re
 import copy
@@ -597,19 +598,19 @@ if __name__ == '__main__':
     EdkLogger.Initialize()
     if len(sys.argv) > 1:
         Br = BuildRule(sys.argv[1])
-        print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "MSFT"][1])
-        print
-        print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "INTEL"][1])
-        print
-        print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "GCC"][1])
-        print
-        print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])
-        print
-        print str(Br[".h", "ACPI_TABLE", "IA32", "INTEL"][1])
-        print
-        print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])
-        print
-        print str(Br[".s", SUP_MODULE_SEC, "IPF", "COMMON"][1])
-        print
-        print str(Br[".s", SUP_MODULE_SEC][1])
+        print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "MSFT"][1]))
+        print()
+        print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "INTEL"][1]))
+        print()
+        print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "GCC"][1]))
+        print()
+        print(str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1]))
+        print()
+        print(str(Br[".h", "ACPI_TABLE", "IA32", "INTEL"][1]))
+        print()
+        print(str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1]))
+        print()
+        print(str(Br[".s", SUP_MODULE_SEC, "IPF", "COMMON"][1]))
+        print()
+        print(str(Br[".s", SUP_MODULE_SEC][1]))
 
diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py 
b/BaseTools/Source/Python/AutoGen/UniClassObject.py
index 06cf3e7d5162..3a931c6f2766 100644
--- a/BaseTools/Source/Python/AutoGen/UniClassObject.py
+++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py
@@ -16,6 +16,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import Common.LongFilePathOs as os, codecs, re
 import distutils.util
 import Common.EdkLogger as EdkLogger
@@ -684,12 +685,12 @@ class UniFileClassObject(object):
     # Show the instance itself
     #
     def ShowMe(self):
-        print self.LanguageDef
+        print(self.LanguageDef)
         #print self.OrderedStringList
         for Item in self.OrderedStringList:
-            print Item
+            print(Item)
             for Member in self.OrderedStringList[Item]:
-                print str(Member)
+                print(str(Member))
 
 # This acts like the main() function for the script, unless it is 'import'ed 
into another
 # script.
diff --git a/BaseTools/Source/Python/BPDG/BPDG.py 
b/BaseTools/Source/Python/BPDG/BPDG.py
index 6c8f89f5d12b..86c44abb67a6 100644
--- a/BaseTools/Source/Python/BPDG/BPDG.py
+++ b/BaseTools/Source/Python/BPDG/BPDG.py
@@ -20,6 +20,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import Common.LongFilePathOs as os
 import sys
 import encodings.ascii
@@ -132,7 +133,7 @@ def MyOptionParser():
 #
 def StartBpdg(InputFileName, MapFileName, VpdFileName, Force):
     if os.path.exists(VpdFileName) and not Force:
-        print "\nFile %s already exist, Overwrite(Yes/No)?[Y]: " % VpdFileName
+        print("\nFile %s already exist, Overwrite(Yes/No)?[Y]: " % VpdFileName)
         choice = sys.stdin.readline()
         if choice.strip().lower() not in ['y', 'yes', '']:
             return
diff --git a/BaseTools/Source/Python/Common/Expression.py 
b/BaseTools/Source/Python/Common/Expression.py
index 7b04dcdb36cc..c63030a16e6e 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -12,6 +12,7 @@
 
 ## Import Modules
 #
+from __future__ import print_function
 from Common.GlobalData import *
 from CommonDataClass.Exceptions import BadExpression
 from CommonDataClass.Exceptions import WrnExpression
@@ -1028,10 +1029,10 @@ if __name__ == '__main__':
         if input in 'qQ':
             break
         try:
-            print ValueExpression(input)(True)
-            print ValueExpression(input)(False)
+            print(ValueExpression(input)(True))
+            print(ValueExpression(input)(False))
         except WrnExpression as Ex:
-            print Ex.result
-            print str(Ex)
+            print(Ex.result)
+            print(str(Ex))
         except Exception as Ex:
-            print str(Ex)
+            print(str(Ex))
diff --git a/BaseTools/Source/Python/Common/RangeExpression.py 
b/BaseTools/Source/Python/Common/RangeExpression.py
index b6f99447057c..4c29bc9ee4bd 100644
--- a/BaseTools/Source/Python/Common/RangeExpression.py
+++ b/BaseTools/Source/Python/Common/RangeExpression.py
@@ -12,6 +12,7 @@
 
 # # Import Modules
 #
+from __future__ import print_function
 from Common.GlobalData import *
 from CommonDataClass.Exceptions import BadExpression
 from CommonDataClass.Exceptions import WrnExpression
@@ -85,11 +86,11 @@ class RangeContainer(object):
         self.__clean__()
         
     def dump(self):
-        print "----------------------"
+        print("----------------------")
         rangelist = ""
         for object in self.rangelist:
             rangelist = rangelist + "[%d , %d]" % (object.start, object.end)
-        print rangelist
+        print(rangelist)
         
         
 class XOROperatorObject(object):   
diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py 
b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
index f8459c892e36..8ba8dd31a8c5 100644
--- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py
+++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py
@@ -14,6 +14,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import Common.LongFilePathOs as os
 import EdkLogger
 import DataType
@@ -158,6 +159,6 @@ def TargetTxtDict(ConfDir):
 if __name__ == '__main__':
     pass
     Target = TargetTxtDict(os.getenv("WORKSPACE"))
-    print 
Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER]
-    print Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET]
-    print Target.TargetTxtDictionary
+    
print(Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER])
+    print(Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET])
+    print(Target.TargetTxtDictionary)
diff --git a/BaseTools/Source/Python/Common/VpdInfoFile.py 
b/BaseTools/Source/Python/Common/VpdInfoFile.py
index 8ff544ed769d..09b8196faf07 100644
--- a/BaseTools/Source/Python/Common/VpdInfoFile.py
+++ b/BaseTools/Source/Python/Common/VpdInfoFile.py
@@ -15,6 +15,7 @@
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
+from __future__ import print_function
 import Common.LongFilePathOs as os
 import re
 import Common.EdkLogger as EdkLogger
@@ -248,7 +249,7 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName):
     except Exception as X:
         EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, 
ExtraData=str(X))
     (out, error) = PopenObject.communicate()
-    print out
+    print(out)
     while PopenObject.returncode is None :
         PopenObject.wait()
     
diff --git a/BaseTools/Source/Python/Ecc/CParser.py 
b/BaseTools/Source/Python/Ecc/CParser.py
index ddc6cbd506aa..80cf278cf87c 100644
--- a/BaseTools/Source/Python/Ecc/CParser.py
+++ b/BaseTools/Source/Python/Ecc/CParser.py
@@ -1,5 +1,6 @@
 # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53
 
+from __future__ import print_function
 from antlr3 import *
 from antlr3.compat import set, frozenset
          
@@ -102,7 +103,7 @@ class CParser(Parser):
         self.postfix_expression_stack = []
 
     def printTokenInfo(self, line, offset, tokenText):
-       print str(line)+ ',' + str(offset) + ':' + str(tokenText)
+       print(str(line)+ ',' + str(offset) + ':' + str(tokenText))
         
     def StorePredicateExpression(self, StartLine, StartOffset, EndLine, 
EndOffset, Text):
        PredExp = CodeFragment.PredicateExpression(Text, (StartLine, 
StartOffset), (EndLine, EndOffset))
diff --git a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py 
b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
index ffa51de7c1bf..2efae2c7c1de 100644
--- a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
+++ b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
@@ -16,6 +16,7 @@
 # Import Modules
 #
 
+from __future__ import print_function
 import re
 import Common.LongFilePathOs as os
 import sys
@@ -533,58 +534,58 @@ class CodeFragmentCollector:
         
     def PrintFragments(self):
         
-        print '################# ' + self.FileName + '#####################'
+        print('################# ' + self.FileName + '#####################')
         
-        print '/****************************************/'
-        print '/*************** COMMENTS ***************/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/*************** COMMENTS ***************/')
+        print('/****************************************/')
         for comment in FileProfile.CommentList:
-            print str(comment.StartPos) + comment.Content
+            print(str(comment.StartPos) + comment.Content)
         
-        print '/****************************************/'
-        print '/********* PREPROCESS DIRECTIVES ********/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/********* PREPROCESS DIRECTIVES ********/')
+        print('/****************************************/')
         for pp in FileProfile.PPDirectiveList:
-            print str(pp.StartPos) + pp.Content
+            print(str(pp.StartPos) + pp.Content)
         
-        print '/****************************************/'
-        print '/********* VARIABLE DECLARATIONS ********/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/********* VARIABLE DECLARATIONS ********/')
+        print('/****************************************/')
         for var in FileProfile.VariableDeclarationList:
-            print str(var.StartPos) + var.Modifier + ' '+ var.Declarator
+            print(str(var.StartPos) + var.Modifier + ' '+ var.Declarator)
             
-        print '/****************************************/'
-        print '/********* FUNCTION DEFINITIONS *********/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/********* FUNCTION DEFINITIONS *********/')
+        print('/****************************************/')
         for func in FileProfile.FunctionDefinitionList:
-            print str(func.StartPos) + func.Modifier + ' '+ func.Declarator + 
' ' + str(func.NamePos)
+            print(str(func.StartPos) + func.Modifier + ' '+ func.Declarator + 
' ' + str(func.NamePos))
             
-        print '/****************************************/'
-        print '/************ ENUMERATIONS **************/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/************ ENUMERATIONS **************/')
+        print('/****************************************/')
         for enum in FileProfile.EnumerationDefinitionList:
-            print str(enum.StartPos) + enum.Content
+            print(str(enum.StartPos) + enum.Content)
         
-        print '/****************************************/'
-        print '/*********** STRUCTS/UNIONS *************/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/*********** STRUCTS/UNIONS *************/')
+        print('/****************************************/')
         for su in FileProfile.StructUnionDefinitionList:
-            print str(su.StartPos) + su.Content
+            print(str(su.StartPos) + su.Content)
             
-        print '/****************************************/'
-        print '/********* PREDICATE EXPRESSIONS ********/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/********* PREDICATE EXPRESSIONS ********/')
+        print('/****************************************/')
         for predexp in FileProfile.PredicateExpressionList:
-            print str(predexp.StartPos) + predexp.Content
+            print(str(predexp.StartPos) + predexp.Content)
         
-        print '/****************************************/'    
-        print '/************** TYPEDEFS ****************/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/************** TYPEDEFS ****************/')
+        print('/****************************************/')
         for typedef in FileProfile.TypedefDefinitionList:
-            print str(typedef.StartPos) + typedef.ToType
+            print(str(typedef.StartPos) + typedef.ToType)
         
 if __name__ == "__main__":
     
     collector = CodeFragmentCollector(sys.argv[1])
     collector.PreprocessFile()
-    print "For Test."
+    print("For Test.")
diff --git a/BaseTools/Source/Python/Ecc/Configuration.py 
b/BaseTools/Source/Python/Ecc/Configuration.py
index 217b60f4f319..4711bbd54fdc 100644
--- a/BaseTools/Source/Python/Ecc/Configuration.py
+++ b/BaseTools/Source/Python/Ecc/Configuration.py
@@ -14,6 +14,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import Common.LongFilePathOs as os
 import Common.EdkLogger as EdkLogger
 from Common.DataType import *
@@ -419,9 +420,9 @@ class Configuration(object):
                 self.__dict__[_ConfigFileToInternalTranslation[List[0]]] = 
List[1]
 
     def ShowMe(self):
-        print self.Filename
+        print(self.Filename)
         for Key in self.__dict__.keys():
-            print Key, '=', self.__dict__[Key]
+            print(Key, '=', self.__dict__[Key])
 
 #
 # test that our dict and out class still match in contents.
diff --git a/BaseTools/Source/Python/Ecc/Exception.py 
b/BaseTools/Source/Python/Ecc/Exception.py
index b0882afa6289..bde41c3a4b57 100644
--- a/BaseTools/Source/Python/Ecc/Exception.py
+++ b/BaseTools/Source/Python/Ecc/Exception.py
@@ -14,6 +14,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 from Xml.XmlRoutines import *
 import Common.LongFilePathOs as os
 
@@ -84,4 +85,4 @@ class ExceptionCheck(object):
 #
 if __name__ == '__main__':
     El = 
ExceptionCheck('C:\\Hess\\Project\\BuildTool\\src\\Ecc\\exception.xml')
-    print El.ExceptionList
+    print(El.ExceptionList)
diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py 
b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py
index fc65e9a2bd3c..a056c3759fb1 100644
--- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py
+++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py
@@ -14,6 +14,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import Common.LongFilePathOs as os
 
 import Common.EdkLogger as EdkLogger
@@ -99,7 +100,7 @@ class Table(object):
         try:
             self.Cur.execute(SqlCommand)
         except Exception as e:
-            print "An error occurred when Drop a table:", e.args[0]
+            print("An error occurred when Drop a table:", e.args[0])
 
     ## Get count
     #
diff --git a/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py 
b/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py
index d5fb80fcf982..811106133cb4 100644
--- a/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py
+++ b/BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py
@@ -15,6 +15,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import xml.dom.minidom
 from Common.LongFilePathSupport import OpenLongFilePath as open
 
@@ -215,7 +216,7 @@ def XmlParseFile(FileName):
         XmlFile.close()
         return Dom
     except Exception as X:
-        print X
+        print(X)
         return ""
 
 # This acts like the main() function for the script, unless it is 'import'ed
@@ -225,5 +226,5 @@ if __name__ == '__main__':
     A = CreateXmlElement('AAA', 'CCC',  [['AAA', '111'], ['BBB', '222']], 
[['A', '1'], ['B', '2']])
     B = CreateXmlElement('ZZZ', 'CCC',  [['XXX', '111'], ['YYY', '222']], 
[['A', '1'], ['B', '2']])
     C = CreateXmlList('DDD', 'EEE', [A, B], ['FFF', 'GGG'])
-    print C.toprettyxml(indent = " ")
+    print(C.toprettyxml(indent = " "))
     pass
diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py
index 99b22725e6ba..e2a5cc8487fa 100644
--- a/BaseTools/Source/Python/Ecc/c.py
+++ b/BaseTools/Source/Python/Ecc/c.py
@@ -11,6 +11,7 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #
 
+from __future__ import print_function
 import sys
 import Common.LongFilePathOs as os
 import re
@@ -2285,7 +2286,7 @@ def CheckDoxygenTripleForwardSlash(FullFileName):
         for Result in ResultSet:
             CommentSet.append(Result)
     except:
-        print 'Unrecognized chars in comment of file %s', FullFileName
+        print('Unrecognized chars in comment of file %s', FullFileName)
 
 
     for Result in CommentSet:
@@ -2438,7 +2439,7 @@ def CheckFuncHeaderDoxygenComments(FullFileName):
         for Result in ResultSet:
             CommentSet.append(Result)
     except:
-        print 'Unrecognized chars in comment of file %s', FullFileName
+        print('Unrecognized chars in comment of file %s', FullFileName)
 
     # Func Decl check
     SqlStatement = """ select Modifier, Name, StartLine, ID, Value
@@ -2469,7 +2470,7 @@ def CheckFuncHeaderDoxygenComments(FullFileName):
         for Result in ResultSet:
             CommentSet.append(Result)
     except:
-        print 'Unrecognized chars in comment of file %s', FullFileName
+        print('Unrecognized chars in comment of file %s', FullFileName)
 
     SqlStatement = """ select Modifier, Header, StartLine, ID, Name
                        from Function
@@ -2634,9 +2635,9 @@ if __name__ == '__main__':
     try:
         test_file = sys.argv[1]
     except IndexError as v:
-        print "Usage: %s filename" % sys.argv[0]
+        print("Usage: %s filename" % sys.argv[0])
         sys.exit(1)
     MsgList = CheckFuncHeaderDoxygenComments(test_file)
     for Msg in MsgList:
-        print Msg
-    print 'Done!'
+        print(Msg)
+    print('Done!')
diff --git a/BaseTools/Source/Python/Eot/CParser.py 
b/BaseTools/Source/Python/Eot/CParser.py
index ddc6cbd506aa..80cf278cf87c 100644
--- a/BaseTools/Source/Python/Eot/CParser.py
+++ b/BaseTools/Source/Python/Eot/CParser.py
@@ -1,5 +1,6 @@
 # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53
 
+from __future__ import print_function
 from antlr3 import *
 from antlr3.compat import set, frozenset
          
@@ -102,7 +103,7 @@ class CParser(Parser):
         self.postfix_expression_stack = []
 
     def printTokenInfo(self, line, offset, tokenText):
-       print str(line)+ ',' + str(offset) + ':' + str(tokenText)
+       print(str(line)+ ',' + str(offset) + ':' + str(tokenText))
         
     def StorePredicateExpression(self, StartLine, StartOffset, EndLine, 
EndOffset, Text):
        PredExp = CodeFragment.PredicateExpression(Text, (StartLine, 
StartOffset), (EndLine, EndOffset))
diff --git a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py 
b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
index 87f179206d84..1e30e2ce62e2 100644
--- a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
+++ b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py
@@ -15,6 +15,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import re
 import Common.LongFilePathOs as os
 import sys
@@ -379,49 +380,49 @@ class CodeFragmentCollector:
     #
     def PrintFragments(self):
 
-        print '################# ' + self.FileName + '#####################'
+        print('################# ' + self.FileName + '#####################')
 
-        print '/****************************************/'
-        print '/*************** ASSIGNMENTS ***************/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/*************** ASSIGNMENTS ***************/')
+        print('/****************************************/')
         for asign in FileProfile.AssignmentExpressionList:
-            print str(asign.StartPos) + asign.Name + asign.Operator + 
asign.Value
+            print(str(asign.StartPos) + asign.Name + asign.Operator + 
asign.Value)
 
-        print '/****************************************/'
-        print '/********* PREPROCESS DIRECTIVES ********/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/********* PREPROCESS DIRECTIVES ********/')
+        print('/****************************************/')
         for pp in FileProfile.PPDirectiveList:
-            print str(pp.StartPos) + pp.Content
+            print(str(pp.StartPos) + pp.Content)
 
-        print '/****************************************/'
-        print '/********* VARIABLE DECLARATIONS ********/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/********* VARIABLE DECLARATIONS ********/')
+        print('/****************************************/')
         for var in FileProfile.VariableDeclarationList:
-            print str(var.StartPos) + var.Modifier + ' '+ var.Declarator
+            print(str(var.StartPos) + var.Modifier + ' '+ var.Declarator)
 
-        print '/****************************************/'
-        print '/********* FUNCTION DEFINITIONS *********/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/********* FUNCTION DEFINITIONS *********/')
+        print('/****************************************/')
         for func in FileProfile.FunctionDefinitionList:
-            print str(func.StartPos) + func.Modifier + ' '+ func.Declarator + 
' ' + str(func.NamePos)
+            print(str(func.StartPos) + func.Modifier + ' '+ func.Declarator + 
' ' + str(func.NamePos))
 
-        print '/****************************************/'
-        print '/************ ENUMERATIONS **************/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/************ ENUMERATIONS **************/')
+        print('/****************************************/')
         for enum in FileProfile.EnumerationDefinitionList:
-            print str(enum.StartPos) + enum.Content
+            print(str(enum.StartPos) + enum.Content)
 
-        print '/****************************************/'
-        print '/*********** STRUCTS/UNIONS *************/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/*********** STRUCTS/UNIONS *************/')
+        print('/****************************************/')
         for su in FileProfile.StructUnionDefinitionList:
-            print str(su.StartPos) + su.Content
+            print(str(su.StartPos) + su.Content)
 
-        print '/****************************************/'
-        print '/************** TYPEDEFS ****************/'
-        print '/****************************************/'
+        print('/****************************************/')
+        print('/************** TYPEDEFS ****************/')
+        print('/****************************************/')
         for typedef in FileProfile.TypedefDefinitionList:
-            print str(typedef.StartPos) + typedef.ToType
+            print(str(typedef.StartPos) + typedef.ToType)
 
 ##
 #
@@ -430,4 +431,4 @@ class CodeFragmentCollector:
 #
 if __name__ == "__main__":
 
-    print "For Test."
+    print("For Test.")
diff --git a/BaseTools/Source/Python/Eot/InfParserLite.py 
b/BaseTools/Source/Python/Eot/InfParserLite.py
index 584a95d6f3e4..24f0d50246e5 100644
--- a/BaseTools/Source/Python/Eot/InfParserLite.py
+++ b/BaseTools/Source/Python/Eot/InfParserLite.py
@@ -14,6 +14,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import Common.LongFilePathOs as os
 import Common.EdkLogger as EdkLogger
 from Common.DataType import *
@@ -164,8 +165,8 @@ if __name__ == '__main__':
     Db.InitDatabase()
     P = 
EdkInfParser(os.path.normpath("C:\Framework\Edk\Sample\Platform\Nt32\Dxe\PlatformBds\PlatformBds.inf"),
 Db, '', '')
     for Inf in P.Sources:
-        print Inf
+        print(Inf)
     for Item in P.Macros:
-        print Item, P.Macros[Item]
+        print(Item, P.Macros[Item])
 
-    Db.Close()
\ No newline at end of file
+    Db.Close()
diff --git a/BaseTools/Source/Python/Eot/c.py b/BaseTools/Source/Python/Eot/c.py
index 8199ce5ee73e..c70f62f393a9 100644
--- a/BaseTools/Source/Python/Eot/c.py
+++ b/BaseTools/Source/Python/Eot/c.py
@@ -15,6 +15,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import sys
 import Common.LongFilePathOs as os
 import re
@@ -384,4 +385,4 @@ if __name__ == '__main__':
     EdkLogger.SetLevel(EdkLogger.QUIET)
     CollectSourceCodeDataIntoDB(sys.argv[1])
 
-    print 'Done!'
+    print('Done!')
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py 
b/BaseTools/Source/Python/GenFds/FdfParser.py
index 20f3e3999b90..a61837e27b31 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -16,6 +16,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import re
 
 import Fd
@@ -4765,7 +4766,7 @@ if __name__ == "__main__":
     try:
         test_file = sys.argv[1]
     except IndexError as v:
-        print "Usage: %s filename" % sys.argv[0]
+        print("Usage: %s filename" % sys.argv[0])
         sys.exit(1)
 
     parser = FdfParser(test_file)
@@ -4773,7 +4774,7 @@ if __name__ == "__main__":
         parser.ParseFile()
         parser.CycleReferenceCheck()
     except Warning as X:
-        print str(X)
+        print(str(X))
     else:
-        print "Success!"
+        print("Success!")
 
diff --git a/BaseTools/Source/Python/GenFds/GenFds.py 
b/BaseTools/Source/Python/GenFds/GenFds.py
index ba3950dacd8a..1552ab4ee3a8 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -15,6 +15,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 from optparse import OptionParser
 import sys
 import Common.LongFilePathOs as os
@@ -689,7 +690,7 @@ class GenFds :
         ModuleDict = BuildDb.BuildObject[DscFile, TAB_COMMON, 
GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules
         for Key in ModuleDict:
             ModuleObj = BuildDb.BuildObject[Key, TAB_COMMON, 
GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]
-            print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType
+            print(ModuleObj.BaseName + ' ' + ModuleObj.ModuleType)
 
     def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj):
         GuidXRefFileName = os.path.join(GenFdsGlobalVariable.FvDir, 
"Guid.xref")
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py 
b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index c1d656227609..73b52030d929 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -15,6 +15,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import Common.LongFilePathOs as os
 import sys
 import subprocess
@@ -736,7 +737,7 @@ class GenFdsGlobalVariable:
             GenFdsGlobalVariable.InfLogger (out)
             GenFdsGlobalVariable.InfLogger (error)
             if PopenObject.returncode != 0:
-                print "###", cmd
+                print("###", cmd)
                 EdkLogger.error("GenFds", COMMAND_FAILURE, errorMess)
 
     def VerboseLogger (msg):
diff --git a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py 
b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
index f40c8bd01b23..d7084fbe88da 100644
--- a/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
+++ b/BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
@@ -17,6 +17,7 @@
 #
 
 #======================================  External Libraries 
========================================
+from __future__ import print_function
 import optparse
 import Common.LongFilePathOs as os
 import re
@@ -216,7 +217,7 @@ if __name__ == '__main__':
     (options, args) = parser.parse_args()
 
     if options.mapfile is None or options.efifile is None:
-        print parser.get_usage()
+        print(parser.get_usage())
     elif os.path.exists(options.mapfile) and os.path.exists(options.efifile):
         list = parsePcdInfoFromMapFile(options.mapfile, options.efifile)
         if list is not None:
@@ -225,6 +226,6 @@ if __name__ == '__main__':
             else:
                 generatePcdTable(list, options.mapfile.replace('.map', 
'.BinaryPcdTable.txt'))
         else:
-            print 'Fail to generate Patch PCD Table based on map file and efi 
file'
+            print('Fail to generate Patch PCD Table based on map file and efi 
file')
     else:
-        print 'Fail to generate Patch PCD Table for fail to find map file or 
efi file!'
+        print('Fail to generate Patch PCD Table for fail to find map file or 
efi file!')
diff --git a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py 
b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
index de8575676cac..4f79d0f82967 100644
--- a/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
+++ b/BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
@@ -19,6 +19,7 @@
 '''
 Pkcs7Sign
 '''
+from __future__ import print_function
 
 import os
 import sys
@@ -113,14 +114,14 @@ if __name__ == '__main__':
   try:
     Process = subprocess.Popen('%s version' % (OpenSslCommand), 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
   except:
-    print 'ERROR: Open SSL command not available.  Please verify PATH or set 
OPENSSL_PATH'
+    print('ERROR: Open SSL command not available.  Please verify PATH or set 
OPENSSL_PATH')
     sys.exit(1)
 
   Version = Process.communicate()
   if Process.returncode <> 0:
-    print 'ERROR: Open SSL command not available.  Please verify PATH or set 
OPENSSL_PATH'
+    print('ERROR: Open SSL command not available.  Please verify PATH or set 
OPENSSL_PATH')
     sys.exit(Process.returncode)
-  print Version[0]
+  print(Version[0])
 
   #
   # Read input file into a buffer and save input filename
@@ -134,7 +135,7 @@ if __name__ == '__main__':
   #
   OutputDir = os.path.dirname(args.OutputFile)
   if not os.path.exists(OutputDir):
-    print 'ERROR: The output path does not exist: %s' % OutputDir
+    print('ERROR: The output path does not exist: %s' % OutputDir)
     sys.exit(1)
   args.OutputFileName = args.OutputFile
 
@@ -170,7 +171,7 @@ if __name__ == '__main__':
         args.SignerPrivateCertFile = open(args.SignerPrivateCertFileName, 'rb')
         args.SignerPrivateCertFile.close()
       except:
-        print 'ERROR: test signer private cert file %s missing' % 
(args.SignerPrivateCertFileName)
+        print('ERROR: test signer private cert file %s missing' % 
(args.SignerPrivateCertFileName))
         sys.exit(1)
 
     #
@@ -196,7 +197,7 @@ if __name__ == '__main__':
         args.OtherPublicCertFile = open(args.OtherPublicCertFileName, 'rb')
         args.OtherPublicCertFile.close()
       except:
-        print 'ERROR: test other public cert file %s missing' % 
(args.OtherPublicCertFileName)
+        print('ERROR: test other public cert file %s missing' % 
(args.OtherPublicCertFileName))
         sys.exit(1)
 
     format = "%dsQ" % len(args.InputFileBuffer)
@@ -242,11 +243,11 @@ if __name__ == '__main__':
         args.TrustedPublicCertFile = open(args.TrustedPublicCertFileName, 'rb')
         args.TrustedPublicCertFile.close()
       except:
-        print 'ERROR: test trusted public cert file %s missing' % 
(args.TrustedPublicCertFileName)
+        print('ERROR: test trusted public cert file %s missing' % 
(args.TrustedPublicCertFileName))
         sys.exit(1)
 
     if not args.SignatureSizeStr:
-      print "ERROR: please use the option --signature-size to specify the size 
of the signature data!"
+      print("ERROR: please use the option --signature-size to specify the size 
of the signature data!")
       sys.exit(1)
     else:
       if args.SignatureSizeStr.upper().startswith('0X'):
@@ -254,10 +255,10 @@ if __name__ == '__main__':
       else:
         SignatureSize = (long)(args.SignatureSizeStr)
     if SignatureSize < 0:
-        print "ERROR: The value of option --signature-size can't be set to 
negative value!"
+        print("ERROR: The value of option --signature-size can't be set to 
negative value!")
         sys.exit(1)
     elif SignatureSize > len(args.InputFileBuffer):
-        print "ERROR: The value of option --signature-size is exceed the size 
of the input file !"
+        print("ERROR: The value of option --signature-size is exceed the size 
of the input file !")
         sys.exit(1)
 
     args.SignatureBuffer = args.InputFileBuffer[0:SignatureSize]
@@ -277,7 +278,7 @@ if __name__ == '__main__':
     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)
     Process.communicate(input=args.SignatureBuffer)[0]
     if Process.returncode <> 0:
-      print 'ERROR: Verification failed'
+      print('ERROR: Verification failed')
       os.remove (args.OutputFileName)
       sys.exit(Process.returncode)
 
diff --git 
a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py 
b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
index 9711de8f5c2e..41bcaa0437c5 100644
--- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
+++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
@@ -22,6 +22,7 @@
 '''
 Rsa2048Sha256GenerateKeys
 '''
+from __future__ import print_function
 
 import os
 import sys
@@ -75,14 +76,14 @@ if __name__ == '__main__':
   try:
     Process = subprocess.Popen('%s version' % (OpenSslCommand), 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
   except:  
-    print 'ERROR: Open SSL command not available.  Please verify PATH or set 
OPENSSL_PATH'
+    print('ERROR: Open SSL command not available.  Please verify PATH or set 
OPENSSL_PATH')
     sys.exit(1)
     
   Version = Process.communicate()
   if Process.returncode <> 0:
-    print 'ERROR: Open SSL command not available.  Please verify PATH or set 
OPENSSL_PATH'
+    print('ERROR: Open SSL command not available.  Please verify PATH or set 
OPENSSL_PATH')
     sys.exit(Process.returncode)
-  print Version[0]
+  print(Version[0])
   
   args.PemFileName = []
   
@@ -103,7 +104,7 @@ if __name__ == '__main__':
       Process = subprocess.Popen('%s genrsa -out %s 2048' % (OpenSslCommand, 
Item.name), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
       Process.communicate()
       if Process.returncode <> 0:
-        print 'ERROR: RSA 2048 key generation failed'
+        print('ERROR: RSA 2048 key generation failed')
         sys.exit(Process.returncode)
       
   #
@@ -125,7 +126,7 @@ if __name__ == '__main__':
     Process = subprocess.Popen('%s rsa -in %s -modulus -noout' % 
(OpenSslCommand, Item), stdout=subprocess.PIPE, stderr=subprocess.PIPE, 
shell=True)
     PublicKeyHexString = Process.communicate()[0].split('=')[1].strip()
     if Process.returncode <> 0:
-      print 'ERROR: Unable to extract public key from private key'
+      print('ERROR: Unable to extract public key from private key')
       sys.exit(Process.returncode)
     PublicKey = ''
     for Index in range (0, len(PublicKeyHexString), 2):
@@ -138,7 +139,7 @@ if __name__ == '__main__':
     Process.stdin.write (PublicKey)
     PublicKeyHash = PublicKeyHash + Process.communicate()[0]
     if Process.returncode <> 0:
-      print 'ERROR: Unable to extract SHA 256 hash of public key'
+      print('ERROR: Unable to extract SHA 256 hash of public key')
       sys.exit(Process.returncode)
 
   #
@@ -171,4 +172,4 @@ if __name__ == '__main__':
   # If verbose is enabled display the public key in C structure format
   #
   if args.Verbose:
-    print 'PublicKeySha256 = ' + PublicKeyHashC    
+    print('PublicKeySha256 = ' + PublicKeyHashC)
diff --git a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py 
b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
index d36a14ffb775..2944b634fb7a 100644
--- a/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
+++ b/BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
@@ -17,6 +17,7 @@
 '''
 Rsa2048Sha256Sign
 '''
+from __future__ import print_function
 
 import os
 import sys
@@ -96,14 +97,14 @@ if __name__ == '__main__':
   try:
     Process = subprocess.Popen('%s version' % (OpenSslCommand), 
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
   except:  
-    print 'ERROR: Open SSL command not available.  Please verify PATH or set 
OPENSSL_PATH'
+    print('ERROR: Open SSL command not available.  Please verify PATH or set 
OPENSSL_PATH')
     sys.exit(1)
     
   Version = Process.communicate()
   if Process.returncode <> 0:
-    print 'ERROR: Open SSL command not available.  Please verify PATH or set 
OPENSSL_PATH'
+    print('ERROR: Open SSL command not available.  Please verify PATH or set 
OPENSSL_PATH')
     sys.exit(Process.returncode)
-  print Version[0]
+  print(Version[0])
   
   #
   # Read input file into a buffer and save input filename
@@ -117,7 +118,7 @@ if __name__ == '__main__':
   #
   OutputDir = os.path.dirname(args.OutputFile)
   if not os.path.exists(OutputDir):
-    print 'ERROR: The output path does not exist: %s' % OutputDir
+    print('ERROR: The output path does not exist: %s' % OutputDir)
     sys.exit(1)
   args.OutputFileName = args.OutputFile
 
@@ -144,7 +145,7 @@ if __name__ == '__main__':
       args.PrivateKeyFile = open(args.PrivateKeyFileName, 'rb')
       args.PrivateKeyFile.close()
     except:
-      print 'ERROR: test signing private key file %s missing' % 
(args.PrivateKeyFileName)
+      print('ERROR: test signing private key file %s missing' % 
(args.PrivateKeyFileName))
       sys.exit(1)
 
   #
@@ -202,14 +203,14 @@ if __name__ == '__main__':
     # Verify that the Hash Type matches the expected SHA256 type
     #
     if uuid.UUID(bytes_le = Header.HashType) <> EFI_HASH_ALGORITHM_SHA256_GUID:
-      print 'ERROR: unsupport hash GUID'
+      print('ERROR: unsupport hash GUID')
       sys.exit(1)
 
     #
     # Verify the public key
     #
     if Header.PublicKey <> PublicKey:
-      print 'ERROR: Public key in input file does not match public key from 
private key file'
+      print('ERROR: Public key in input file does not match public key from 
private key file')
       sys.exit(1)
 
     FullInputFileBuffer = args.InputFileBuffer
@@ -228,7 +229,7 @@ if __name__ == '__main__':
     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)
     Process.communicate(input=FullInputFileBuffer)
     if Process.returncode <> 0:
-      print 'ERROR: Verification failed'
+      print('ERROR: Verification failed')
       os.remove (args.OutputFileName)
       sys.exit(Process.returncode)
 
diff --git a/BaseTools/Source/Python/TargetTool/TargetTool.py 
b/BaseTools/Source/Python/TargetTool/TargetTool.py
index 9fb89549cc29..0d4a59198e7b 100644
--- a/BaseTools/Source/Python/TargetTool/TargetTool.py
+++ b/BaseTools/Source/Python/TargetTool/TargetTool.py
@@ -12,6 +12,7 @@
 #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
 #
 
+from __future__ import print_function
 import Common.LongFilePathOs as os
 import sys
 import traceback
@@ -32,7 +33,7 @@ class TargetTool():
         self.Arg       = args[0]
         self.FileName  = os.path.normpath(os.path.join(self.WorkSpace, 'Conf', 
'target.txt'))
         if os.path.isfile(self.FileName) == False:
-            print "%s does not exist." % self.FileName
+            print("%s does not exist." % self.FileName)
             sys.exit(1)
         self.TargetTxtDictionary = {
             TAB_TAT_DEFINES_ACTIVE_PLATFORM                            : None,
@@ -83,14 +84,14 @@ class TargetTool():
         errMsg  = ''
         for Key in self.TargetTxtDictionary:
             if type(self.TargetTxtDictionary[Key]) == type([]):
-                print "%-30s = %s" % (Key, ''.join(elem + ' ' for elem in 
self.TargetTxtDictionary[Key]))
+                print("%-30s = %s" % (Key, ''.join(elem + ' ' for elem in 
self.TargetTxtDictionary[Key])))
             elif self.TargetTxtDictionary[Key] is None:
                 errMsg += "  Missing %s configuration information, please use 
TargetTool to set value!" % Key + os.linesep 
             else:
-                print "%-30s = %s" % (Key, self.TargetTxtDictionary[Key])
+                print("%-30s = %s" % (Key, self.TargetTxtDictionary[Key]))
         
         if errMsg != '':
-            print os.linesep + 'Warning:' + os.linesep + errMsg
+            print(os.linesep + 'Warning:' + os.linesep + errMsg)
             
     def RWFile(self, CommentCharacter, KeySplitCharacter, Num):
         try:
@@ -109,7 +110,7 @@ class TargetTool():
                             if Key not in existKeys:
                                 existKeys.append(Key)
                             else:
-                                print "Warning: Found duplicate key item in 
original configuration files!"
+                                print("Warning: Found duplicate key item in 
original configuration files!")
                                 
                             if Num == 0:
                                 Line = "%-30s = \n" % Key
@@ -120,7 +121,7 @@ class TargetTool():
                             fw.write(Line)
             for key in self.TargetTxtDictionary:
                 if key not in existKeys:
-                    print "Warning: %s does not exist in original 
configuration file" % key
+                    print("Warning: %s does not exist in original 
configuration file" % key)
                     Line = GetConfigureKeyValue(self, key)
                     if Line is None:
                         Line = "%-30s = " % key
@@ -223,25 +224,25 @@ if __name__ == '__main__':
     EdkLogger.Initialize()
     EdkLogger.SetLevel(EdkLogger.QUIET)
     if os.getenv('WORKSPACE') is None:
-        print "ERROR: WORKSPACE should be specified or edksetup script should 
be executed before run TargetTool"
+        print("ERROR: WORKSPACE should be specified or edksetup script should 
be executed before run TargetTool")
         sys.exit(1)
         
     (opt, args) = MyOptionParser()
     if len(args) != 1 or (args[0].lower() != 'print' and args[0].lower() != 
'clean' and args[0].lower() != 'set'):
-        print "The number of args isn't 1 or the value of args is invalid."
+        print("The number of args isn't 1 or the value of args is invalid.")
         sys.exit(1)
     if opt.NUM is not None and opt.NUM < 1:
-        print "The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0."
+        print("The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0.")
         sys.exit(1)
     if opt.TARGET is not None and len(opt.TARGET) > 1:
         for elem in opt.TARGET:
             if elem == '0':
-                print "0 will clear the TARGET setting in target.txt and can't 
combine with other value."
+                print("0 will clear the TARGET setting in target.txt and can't 
combine with other value.")
                 sys.exit(1)
     if opt.TARGET_ARCH is not None and len(opt.TARGET_ARCH) > 1:
         for elem in opt.TARGET_ARCH:
             if elem == '0':
-                print "0 will clear the TARGET_ARCH setting in target.txt and 
can't combine with other value."
+                print("0 will clear the TARGET_ARCH setting in target.txt and 
can't combine with other value.")
                 sys.exit(1)
 
     try:
diff --git a/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py 
b/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py
index ca21e6995217..afa5b2407ec5 100644
--- a/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py
+++ b/BaseTools/Source/Python/UPT/Library/ExpressionValidate.py
@@ -14,6 +14,7 @@
 '''
 ExpressionValidate
 '''
+from __future__ import print_function
 
 ##
 # Import Modules
@@ -566,7 +567,7 @@ def IsValidFeatureFlagExp(Token, Flag=False):
 
 if __name__ == '__main__':
 #    print IsValidRangeExpr('LT 9')
-    print 
_LogicalExpressionParser('gCrownBayTokenSpaceGuid.PcdPciDevice1BridgeAddressLE0').IsValidLogicalExpression()
+    
print(_LogicalExpressionParser('gCrownBayTokenSpaceGuid.PcdPciDevice1BridgeAddressLE0').IsValidLogicalExpression())
 
 
     
diff --git a/BaseTools/Source/Python/UPT/Library/UniClassObject.py 
b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
index 299cd871444b..a464cbf702f7 100644
--- a/BaseTools/Source/Python/UPT/Library/UniClassObject.py
+++ b/BaseTools/Source/Python/UPT/Library/UniClassObject.py
@@ -14,6 +14,7 @@
 """
 Collect all defined strings in multiple uni files
 """
+from __future__ import print_function
 
 ##
 # Import Modules
@@ -730,7 +731,7 @@ class UniFileClassObject(object):
                     EdkLogger.Error("Unicode File Parser", 
ToolError.FORMAT_INVALID, ExtraData=File.Path)
                 NewLines.append(Line)
             else:
-                print Line
+                print(Line)
                 EdkLogger.Error("Unicode File Parser", 
ToolError.FORMAT_INVALID, ExtraData=File.Path)
                     
         if StrName and not StrName.split()[1].startswith(u'STR_'):
@@ -1022,12 +1023,12 @@ class UniFileClassObject(object):
     # Show the instance itself
     #
     def ShowMe(self):
-        print self.LanguageDef
+        print(self.LanguageDef)
         #print self.OrderedStringList
         for Item in self.OrderedStringList:
-            print Item
+            print(Item)
             for Member in self.OrderedStringList[Item]:
-                print str(Member)
+                print(str(Member))
     
     #
     # Read content from '!include' UNI file 
diff --git a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py 
b/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py
index 436dc90e6dd3..074aa311f31d 100644
--- a/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py
+++ b/BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py
@@ -15,6 +15,7 @@
 '''
 DecPomAlignment
 '''
+from __future__ import print_function
 
 ##
 # Import Modules
@@ -902,47 +903,47 @@ class DecPomAlignment(PackageObject):
     # Print all members and their values of Package class
     #
     def ShowPackage(self):
-        print '\nName =', self.GetName()
-        print '\nBaseName =', self.GetBaseName()
-        print '\nVersion =', self.GetVersion() 
-        print '\nGuid =', self.GetGuid()
+        print('\nName =', self.GetName())
+        print('\nBaseName =', self.GetBaseName())
+        print('\nVersion =', self.GetVersion())
+        print('\nGuid =', self.GetGuid())
         
-        print '\nStandardIncludes = %d ' \
-            % len(self.GetStandardIncludeFileList()),
+        print('\nStandardIncludes = %d ' \
+            % len(self.GetStandardIncludeFileList()), end=' ')
         for Item in self.GetStandardIncludeFileList():
-            print Item.GetFilePath(), '  ', Item.GetSupArchList()
-        print '\nPackageIncludes = %d \n' \
-            % len(self.GetPackageIncludeFileList()),
+            print(Item.GetFilePath(), '  ', Item.GetSupArchList())
+        print('\nPackageIncludes = %d \n' \
+            % len(self.GetPackageIncludeFileList()), end=' ')
         for Item in self.GetPackageIncludeFileList():
-            print Item.GetFilePath(), '  ', Item.GetSupArchList()
+            print(Item.GetFilePath(), '  ', Item.GetSupArchList())
              
-        print '\nGuids =', self.GetGuidList()
+        print('\nGuids =', self.GetGuidList())
         for Item in self.GetGuidList():
-            print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()
-        print '\nProtocols =', self.GetProtocolList()
+            print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList())
+        print('\nProtocols =', self.GetProtocolList())
         for Item in self.GetProtocolList():
-            print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()
-        print '\nPpis =', self.GetPpiList()
+            print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList())
+        print('\nPpis =', self.GetPpiList())
         for Item in self.GetPpiList():
-            print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()
-        print '\nLibraryClasses =', self.GetLibraryClassList()
+            print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList())
+        print('\nLibraryClasses =', self.GetLibraryClassList())
         for Item in self.GetLibraryClassList():
-            print Item.GetLibraryClass(), Item.GetRecommendedInstance(), \
-            Item.GetSupArchList()
-        print '\nPcds =', self.GetPcdList()
+            print(Item.GetLibraryClass(), Item.GetRecommendedInstance(), \
+            Item.GetSupArchList())
+        print('\nPcds =', self.GetPcdList())
         for Item in self.GetPcdList():
-            print 'CName=', Item.GetCName(), 'TokenSpaceGuidCName=', \
+            print('CName=', Item.GetCName(), 'TokenSpaceGuidCName=', \
                 Item.GetTokenSpaceGuidCName(), \
                 'DefaultValue=', Item.GetDefaultValue(), \
                 'ValidUsage=', Item.GetValidUsage(), \
                 'SupArchList', Item.GetSupArchList(), \
-                'Token=', Item.GetToken(), 'DatumType=', Item.GetDatumType()
+                'Token=', Item.GetToken(), 'DatumType=', Item.GetDatumType())
  
         for Item in self.GetMiscFileList():
-            print Item.GetName()
+            print(Item.GetName())
             for FileObjectItem in Item.GetFileList():
-                print FileObjectItem.GetURI()
-        print '****************\n'
+                print(FileObjectItem.GetURI())
+        print('****************\n')
 
 ## GenPcdDeclaration
 #
diff --git a/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py 
b/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py
index 8b4ece2617a1..5f0abcafef27 100644
--- a/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py
+++ b/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py
@@ -11,6 +11,7 @@
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
+from __future__ import print_function
 import os
 import unittest
 
@@ -66,7 +67,7 @@ def TestTemplate(TestString, TestFunc):
         # Close file
         f.close()
     except:
-        print 'Can not create temporary file [%s]!' % Path
+        print('Can not create temporary file [%s]!' % Path)
         exit(-1)
 
     # Call test function to test
@@ -279,6 +280,6 @@ if __name__ == '__main__':
     unittest.FunctionTestCase(TestDecPcd).runTest()
     unittest.FunctionTestCase(TestDecUserExtension).runTest()
 
-    print 'All tests passed...'
+    print('All tests passed...')
 
 
diff --git a/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py 
b/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py
index f3b43ee0bc27..626f17426de7 100644
--- a/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py
+++ b/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py
@@ -11,6 +11,7 @@
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
+from __future__ import print_function
 import os
 #import Object.Parser.InfObject as InfObject
 from Object.Parser.InfCommonObject import CurrentLine
@@ -271,7 +272,7 @@ def PrepareTest(String):
                 TempFile  = open (FileName, "w")    
                 TempFile.close()
             except:
-                print "File Create Error"
+                print("File Create Error")
         CurrentLine = CurrentLine()
         CurrentLine.SetFileName("Test")
         CurrentLine.SetLineString(Item[0])
@@ -376,11 +377,11 @@ if __name__ == '__main__':
             try:
                 InfBinariesInstance.SetBinary(Ver = Ver, ArchList = ArchList)
             except:
-                print "Test Failed!"
+                print("Test Failed!")
                 AllPassedFlag = False
     
     if AllPassedFlag :
-        print 'All tests passed...'
+        print('All tests passed...')
     else:
-        print 'Some unit test failed!'
+        print('Some unit test failed!')
 
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index a001162e8e3b..7f289c103fb9 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -17,6 +17,7 @@
 #  This class is used to retrieve information stored in database and convert 
them
 # into PlatformBuildClassObject form for easier use for AutoGen.
 #
+from __future__ import print_function
 from Common.StringUtils import *
 from Common.DataType import *
 from Common.Misc import *
@@ -1373,7 +1374,7 @@ class DscBuildData(PlatformBuildClassObject):
             for (skuname,StoreName,PcdGuid,PcdName,PcdValue) in Str_Pcd_Values:
                 str_pcd_obj = S_pcd_set.get((PcdName, PcdGuid))
                 if str_pcd_obj is None:
-                    print PcdName, PcdGuid
+                    print(PcdName, PcdGuid)
                     raise
                 if str_pcd_obj.Type in 
[self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],
                                         
self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:
@@ -1808,7 +1809,7 @@ class DscBuildData(PlatformBuildClassObject):
                         EdkLogger.error('Build', FORMAT_INVALID, "Invalid 
value format for %s. From %s Line %d " %
                                         (".".join((Pcd.TokenSpaceGuidCName, 
Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2]))
                     except:
-                        print "error"
+                        print("error")
                 try:
                     Value, ValueSize = ParseFieldValue 
(FieldList[FieldName][0])
                 except Exception:
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py 
b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index a8f13d52c42d..2815c83af1b3 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -15,6 +15,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import Common.LongFilePathOs as os
 import re
 import time
@@ -1639,7 +1640,7 @@ class DscParser(MetaFileParser):
         try:
             self._ValueList[2] = '|'.join(ValList)
         except Exception:
-            print ValList
+            print(ValList)
 
     def __ProcessComponent(self):
         self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros)
diff --git a/BaseTools/Source/Python/build/build.py 
b/BaseTools/Source/Python/build/build.py
index 4600c46be1be..416aa73549d1 100644
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -16,6 +16,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import Common.LongFilePathOs as os
 import re
 import StringIO
@@ -2195,7 +2196,7 @@ class Build():
                     toolsFile = os.path.join(FvDir, 'GuidedSectionTools.txt')
                     toolsFile = open(toolsFile, 'wt')
                     for guidedSectionTool in guidAttribs:
-                        print >> toolsFile, ' '.join(guidedSectionTool)
+                        print(' '.join(guidedSectionTool), file=toolsFile)
                     toolsFile.close()
 
     ## Returns the full path of the tool.
diff --git a/BaseTools/Tests/TestTools.py b/BaseTools/Tests/TestTools.py
index 27afd79f2094..be7b4ad42856 100644
--- a/BaseTools/Tests/TestTools.py
+++ b/BaseTools/Tests/TestTools.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
 ## @file
 # Utility functions and classes for BaseTools unit tests
 #
@@ -91,9 +92,9 @@ class BaseToolsTest(unittest.TestCase):
             os.remove(path)
 
     def DisplayBinaryData(self, description, data):
-        print description, '(base64 encoded):'
+        print(description, '(base64 encoded):')
         b64data = base64.b64encode(data)
-        print b64data
+        print(b64data)
 
     def DisplayFile(self, fileName):
         sys.stdout.write(self.ReadTmpFile(fileName))
diff --git a/BaseTools/Tests/TianoCompress.py b/BaseTools/Tests/TianoCompress.py
index e14136416211..f6a4a6ae9c5d 100644
--- a/BaseTools/Tests/TianoCompress.py
+++ b/BaseTools/Tests/TianoCompress.py
@@ -15,6 +15,7 @@
 ##
 # Import Modules
 #
+from __future__ import print_function
 import os
 import random
 import sys
@@ -52,8 +53,8 @@ class Tests(TestTools.BaseToolsTest):
         finish = self.ReadTmpFile('output2')
         startEqualsFinish = start == finish
         if not startEqualsFinish:
-            print
-            print 'Original data did not match decompress(compress(data))'
+            print()
+            print('Original data did not match decompress(compress(data))')
             self.DisplayBinaryData('original data', start)
             self.DisplayBinaryData('after compression', 
self.ReadTmpFile('output1'))
             self.DisplayBinaryData('after decomression', finish)
diff --git a/BaseTools/gcc/mingw-gcc-build.py b/BaseTools/gcc/mingw-gcc-build.py
index 858b4020ef9f..643fec58a457 100755
--- a/BaseTools/gcc/mingw-gcc-build.py
+++ b/BaseTools/gcc/mingw-gcc-build.py
@@ -17,6 +17,7 @@
 #
 
 
+from __future__ import print_function
 from optparse import OptionParser
 import os
 import shutil
@@ -34,7 +35,7 @@ if sys.version_info < (2, 5):
     #
     # 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.')
     sys.exit(-1)
 
 #
@@ -146,37 +147,37 @@ class Config:
         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!")
+            print()
+            print("Please try using --help and then change the configuration.")
             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:")
+        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()
         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()
+            print("Please try using --help and then change the configuration.")
             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()
+            print('Please note that the IPF compiler built by this script has')
+            print('not yet been validated!')
+            print()
             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()
+                print("Please try using --help and then change the 
configuration.")
                 return False
 
-        print
+        print()
         return True
 
     def Relative(self, path):
@@ -275,7 +276,7 @@ class SourceFiles:
             wDots = (100 * received * blockSize) / fileSize / 10
             if wDots > self.dots:
                 for i in range(wDots - self.dots):
-                    print '.',
+                    print('.', end=' ')
                     sys.stdout.flush()
                     self.dots += 1
 
@@ -286,18 +287,18 @@ class SourceFiles:
                     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)
                     if retries > 0:
-                        print '(retry)',
+                        print('(retry)', end=' ')
                     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=' ')
                         else:
-                            print '[md5 mismatch]',
+                            print('[md5 mismatch]', end=' ')
                         sys.stdout.flush()
                         completed = md5_pass
 
@@ -313,32 +314,32 @@ class SourceFiles:
                     if not completed and os.path.exists(local_file):
                         md5_pass = self.checkHash(fdata)
                         if md5_pass:
-                            print '[md5 match]',
+                            print('[md5 match]', end=' ')
                         else:
-                            print '[md5 mismatch]',
+                            print('[md5 mismatch]', end=' ')
                         sys.stdout.flush()
                         completed = md5_pass
 
                     if completed:
-                        print '[done]'
+                        print('[done]')
                         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]')
+                        print('  Tried to retrieve', url)
+                        print('  to', local_file)
+                        print('Possible fixes:')
+                        print('* If you are behind a web-proxy, try setting 
the', end=' ')
+                        print('http_proxy environment variable')
+                        print('* You can try to download this file 
separately', end=' ')
+                        print('and rerun this script')
                         raise Exception()
                 
                 except KeyboardInterrupt:
-                    print '[KeyboardInterrupt]'
+                    print('[KeyboardInterrupt]')
                     return False
 
                 except Exception as e:
-                    print e
+                    print(e)
 
             if not completed: return False
 
@@ -396,7 +397,7 @@ class Extracter:
             extractedMd5 = open(extracted).read()
 
         if extractedMd5 != moduleMd5:
-            print 'Extracting %s:' % self.config.Relative(local_file)
+            print('Extracting %s:' % self.config.Relative(local_file))
             tar = tarfile.open(local_file)
             tar.extractall(extractDst)
             open(extracted, 'w').write(moduleMd5)
@@ -480,7 +481,7 @@ class Builder:
 
         os.chdir(base_dir)
 
-        print '%s module is now built and installed' % module
+        print('%s module is now built and installed' % module)
 
     def RunCommand(self, cmd, module, stage, skipable=False):
         if skipable:
@@ -495,13 +496,13 @@ class Builder:
                 stderr=subprocess.STDOUT
                 )
 
-        print '%s [%s] ...' % (module, stage),
+        print('%s [%s] ...' % (module, stage), end=' ')
         sys.stdout.flush()
         p = popen(cmd)
         output = p.stdout.read()
         p.wait()
         if p.returncode != 0:
-            print '[failed!]'
+            print('[failed!]')
             logFile = os.path.join(self.config.build_dir, 'log.txt')
             f = open(logFile, "w")
             f.write(output)
@@ -509,7 +510,7 @@ class Builder:
             raise Exception, 'Failed to %s %s\n' % (stage, module) + \
                 'See output log at %s' % self.config.Relative(logFile)
         else:
-            print '[done]'
+            print('[done]')
 
         if skipable:
             self.MarkBuildStepComplete('%s.%s' % (module, stage))
@@ -526,13 +527,13 @@ class Builder:
             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=' ')
                     startPrinted = True
-                print link,
+                print(link, end=' ')
                 os.symlink(src, linkdst)
 
         if startPrinted:
-            print '[done]'
+            print('[done]')
 
 class App:
     """class App
@@ -551,9 +552,9 @@ class App:
         sources = SourceFiles(config)
         result = sources.GetAll()
         if result:
-            print 'All files have been downloaded & verified'
+            print('All files have been downloaded & verified')
         else:
-            print 'An error occured while downloading a file'
+            print('An error occured while downloading a file')
             return
 
         Extracter(sources, config).ExtractAll()
-- 
2.17.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to