0

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()
Bolu
  • 8,696
  • 4
  • 38
  • 70
Kyle
  • 2,339
  • 10
  • 33
  • 67

1 Answers1

0

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.
Kyle
  • 2,339
  • 10
  • 33
  • 67
  • 1
    use `r"C:\Python\n\f"` instead of `"C:\Python\n\f"`. The latter has literal newline (`"\n"`) in it. Use `os.path.join(keyworddir, item)` instead of `keyworddir + "\\" + item` – jfs May 14 '14 at 13:11