Code: Alles auswählen
#!/usr/bin/env python
import os
import sys
import subprocess
for x in os.walk(r"C:\Users\Sr4l\DreamInCode\C\source"):
for y in x[2]:
if os.path.isfile(os.path.join(x[0],y)) and y.endswith(".c"):
proc = subprocess.Popen('C:\Windows\System32\cmd.exe',
shell=True,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
)
print proc.communicate("""
cd C:/cygwin/bin/ \n\r
gcc.exe -o %s.exe %s\n\r
"""%(
os.path.join(x[0],y).replace("source", "build")[:-2],
os.path.join(x[0],y)))
Meine Frage ist:
Warum wird nach `proc.communicate` die Datei geschlossen, so das ich nicht nochmal `proc.communicate` nutzen kann?