I am stuck in a while True loop which I can't seem to break, any suggestions please:
command1 = transporterLink + " -m verify -f " + indir1 + " -u " + username + " -p " + password + " -o " + indir1 + "/VerifyLog.txt -s " + provider1 + " -v eXtreme"
master, slave = pty.openpty()
process = Popen(command1, shell=True, stdin=PIPE, stdout=slave, stderr=slave, close_fds=True)
stdout = os.fdopen(master)
while True:
wx.Yield()
line = stdout.readline()
print line.rstrip()
if not line:
break
process.wait()
eis
53.8k14 gold badges159 silver badges206 bronze badges
asked Feb 9, 2014 at 20:55
speedyrazor
3,26510 gold badges35 silver badges55 bronze badges
2 Answers 2
The simplest explanation is that you never get an empty line from stdout. Note that print line.rstrip() does not modify line; for example, if the last line ended with a newline, the loop would continue.
answered Feb 9, 2014 at 20:59
NPE
503k114 gold badges970 silver badges1k bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
speedyrazor
Thanks NPE, any suggestions on how I could get out of this loop when at the end?
SethMMorton
@speedyrazor You might consider
if not line.strip(): instead.Sorted. I know that at the end of the last line it will return one of two strings so just needed to search for either of these two:
process = Popen(command1, shell=True, stdin=PIPE, stdout=slave, stderr=slave, close_fds=True)
stdout = os.fdopen(master)
while True:
wx.Yield()
line = stdout.readline()
line = line.rstrip()
print line
if "Returning 1" in line:
break
if "Returning 0" in line:
break
answered Feb 10, 2014 at 6:05
speedyrazor
3,26510 gold badges35 silver badges55 bronze badges
Comments
lang-py
stdout?