I am creating simple HTML with a button. When the user clicks the button, he calls the server-side Python file. In the Python file, I use Popen to call the Powershell script, as shown below:
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 Powershell takes a long time to complete (and generate a lot of results at runtime). After the user clicks the button, the browser displays “Wait xxx” for about a few minutes until the python code is fully executed.
Question: how can I get Powershell output at runtime and update the output in a timely manner in the browser?
Landy source
share