0

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
1
  • 1
    Do you ever get an empty line from stdout? Commented Feb 9, 2014 at 20:57

2 Answers 2

4

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
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks NPE, any suggestions on how I could get out of this loop when at the end?
@speedyrazor You might consider if not line.strip(): instead.
0

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

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.