NameError: Name 'buffer' Is Not Defined With Ant Based Framework Batch File
I'm using a python script to execute an Ant based framework batch file(Helium.bat) subprocess.Popen('hlm '+commands, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) How
Solution 1:
I think at least part of the problem is how you're executing the batch file. Give this a try:
# execute the batch file as a separate process and echo its output
Popen_kwargs = { 'stdout': subprocess.PIPE, 'stderr': subprocess.STDOUT,
'universal_newlines': True }
with subprocess.Popen('hlm '+commands, **Popen_kwargs).stdout as output:
for line in output:
print line,
This pass different arguments to Popen
-- the difference are this version removes the shell=True
which isn't needed on a batch file, sets stderr=subprocess.STDOUT
which redirects stdout
to the same place stdout is going to to avoid missing any error messages, and adds a universal_newlines=True
to make the output more readable.
Another difference is it reads and prints the output from the Popen
process which will effectively make the Python script running the batch file wait until it's finished executing before continuing on -- which I suspect is important.
Post a Comment for "NameError: Name 'buffer' Is Not Defined With Ant Based Framework Batch File"