Python Popen pty,AttributeError:'list'对象没有属性'rstrip'

时间:2014-02-12 10:29:11

标签: python popen pty

我对以下代码有两个问题。 问题1是pty在Windows上不起作用,适用于MAC,但我需要此应用程序在所有平台上运行。 问题2是运行时我得到AttributeError: 'list' object has no attribute 'rstrip',不知道如何解决这两个问题。

command1 = transporterLink + " -m verify -f " + indir1 + " -u " + username + " -p " + password + " -o " + logPath + " -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)
import select
q = select.poll()
q.register(stdout,select.POLLIN)
global subject
subject = "Test"
while True:
    wx.Yield()
    line = q.poll()
    if not line:
        continue # no input
    else:
        line = line.rstrip()
        print line
        if "Returning 1" in line:
            result1 = "Verify FAILED!"
            subject = "FAILED! - "
            self.sendEmail(self)
            break
        if "Returning 0" in line:
            result1 = "Verify PASSED!"
            subject = "PASSED! - "
            self.sendEmail(self)
            break

1 个答案:

答案 0 :(得分:0)

q.poll返回一个列表。列表没有rstrip方法。