Python Pexpect期望获取timedout错误

2024-04-25 07:19:09 发布

您现在位置:Python中文网/ 问答频道 /正文

expect功能已超时。我张贴我的代码和手动完成时的步骤

import pexpect
from pexpect import popen_spawn
child = popen_spawn.PopenSpawn('tibemsadmin -server localhost:7222 -user admin -password admin', cwd='C:/tibco/ems/8.5 - Copy/bin')
out = child.sendline('delete queue zzzzzzz')
child.expect('Are you sure (yes,no)?')
print(out)

手动完成时:

C:\tibco\ems\8.5 - Copy\bin>tibemsadmin -server localhost:7222 -user admin -password admin

TIBCO Enterprise Message Service Administration Tool.
Copyright 2003-2019 by TIBCO Software Inc.
All rights reserved.

Version 8.5.1 V4 9/12/2019

Connected to: tcp://localhost:7222
Type 'help' for commands help, 'exit' to exit:
tcp://localhost:7222> delete queue zzzzzzz
Are you sure (yes,no)? yes
Queue 'zzzzzzz' has been deleted
tcp://localhost:7222>

错误:

  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pexpect\expect.py", line 144, in timeout
    raise exc
pexpect.exceptions.TIMEOUT: <pexpect.popen_spawn.PopenSpawn object at 0x019AE790>
searcher: searcher_re:
    0: re.compile(b'Are you sure (yes,no)?')
<pexpect.popen_spawn.PopenSpawn object at 0x019AE790>
searcher: searcher_re:
    0: re.compile(b'Are you sure (yes,no)?')

Tags: noreyouchildlocalhostadminareyes