I create a simple HTML with a button. When user clicks the button, it will call a Python file executed in server side. In the Python file, I use Popen to call a Powershell script, like below code:
command_line = r'"C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe" -psc "C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\vim.psc1" -noe -c ". \"C:\DoSth\DoSth.ps1\""'
args = shlex.split(command_line)
sys.stdout.flush()
retcode = subprocess.Popen(args)
But the Powershell requires a long time to finish(and generate lots of output during execution). After user clicks the button, the browser shows "Waiting for xxx" about several minutes until the python code executed completely.
The question is: how can I get the Powershell's output during the execution, and update the output to browser in time?