Question

The code below works completely fine. However, once the subprocess is called and the external python script is executed it starts popping up rapidly a command prompt as the output of the script is plain text. However, we have tried everything to disable that pop up. We tried adding 'shell=False' and 'shell=None'. We even tried to edit the external script itself and modify its subprocess calls but it has none.

if os.path.exists(oldpath): shutil.copy(root.wgetdir + "\\" + root.website.get() + "\\" + item, keyworddir + "\\" + item)
            shellreturn = subprocess.check_output(["C:\Python34\python",root.wgetdir + "\html2text.py", keyworddir + "\\" + item])
            print(shellreturn)
            shelllist = shellreturn.decode().splitlines()
Was it helpful?

Solution

Thanks to the related post from @J.F. Sebastian, I was able to figure out how to eliminate the shell popup. Below is the code I used.

startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW      
shellreturn = subprocess.check_output(["C:\Python34\python", root.wgetdir + "\html2text.py", keyworddir + "\\" + item], startupinfo=startupinfo) #this could be any subprocess.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top