BaseTools: Update python tool to call external tools with shell true mode

Python tool may run from source as the dos batch files. So, update python
code to call external tools with shell true mode.

Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Erik Bjorge <erik.c.bjorge@intel.com>
This commit is contained in:
Liming Gao 2016-09-12 15:22:49 +08:00
parent bf069759ef
commit 71f5913eb9
2 changed files with 6 additions and 4 deletions

View File

@ -233,14 +233,15 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName):
OutputBinFileName = os.path.join(OutputDir, "%s.bin" % BaseName) OutputBinFileName = os.path.join(OutputDir, "%s.bin" % BaseName)
try: try:
PopenObject = subprocess.Popen([ToolPath, PopenObject = subprocess.Popen(' '.join([ToolPath,
'-o', OutputBinFileName, '-o', OutputBinFileName,
'-m', OutputMapFileName, '-m', OutputMapFileName,
'-q', '-q',
'-f', '-f',
VpdFileName], VpdFileName]),
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr= subprocess.PIPE) stderr= subprocess.PIPE,
shell=True)
except Exception, X: except Exception, X:
EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData="%s" % (str(X))) EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData="%s" % (str(X)))
(out, error) = PopenObject.communicate() (out, error) = PopenObject.communicate()

View File

@ -268,12 +268,13 @@ def LaunchCommand(Command, WorkingDir):
if not isinstance(Command, list): if not isinstance(Command, list):
if platform.system() != 'Windows': if platform.system() != 'Windows':
Command = Command.split() Command = Command.split()
Command = ' '.join(Command)
Proc = None Proc = None
EndOfProcedure = None EndOfProcedure = None
try: try:
# launch the command # launch the command
Proc = Popen(Command, stdout=PIPE, stderr=PIPE, env=os.environ, cwd=WorkingDir, bufsize=-1) Proc = Popen(Command, stdout=PIPE, stderr=PIPE, env=os.environ, cwd=WorkingDir, bufsize=-1, shell=True)
# launch two threads to read the STDOUT and STDERR # launch two threads to read the STDOUT and STDERR
EndOfProcedure = Event() EndOfProcedure = Event()