我有一个需求,我需要自动回答远程机器上的提示,然后在阅读了不同的 stackoverflow 问题后我发现了 fexpect。但是,当我在脚本中包含 fexpect 时,它会破坏整个脚本!
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/fabric/main.py", line 743, in main
*args, **kwargs
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 368, in execute
multiprocessing
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 264, in _execute
return task.run(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/fabric/tasks.py", line 171, in run
return self.wrapped(*args, **kwargs)
File "/etc/puppet/fabfile.py", line 165, in edit_sudoers
run('echo "Current Permission of the file /etc/sudoers - "`stat -c "%a %n" /etc/sudoers`')
File "/usr/local/lib/python2.7/dist-packages/ilogue/fexpect/api.py", line 15, in run
wrappedCmd = wrapExpectations(cmd)
File "/usr/local/lib/python2.7/dist-packages/ilogue/fexpect/internals.py", line 15, in wrapExpectations
script = createScript(cmd)
File "/usr/local/lib/python2.7/dist-packages/ilogue/fexpect/internals.py", line 39, in createScript
for e in fabric.state.env.expectations:
File "/usr/local/lib/python2.7/dist-packages/fabric/utils.py", line 184, in __getattr__
raise AttributeError(key)
AttributeError: expectations
我写
from ilogue.fexpect import expect, expecting, run
织物的那一刻停止使用上述错误消息。
我也在fabric irc中问过,但我知道这可能是因为一些版本相关的问题。以前有没有其他人遇到过这个错误?
fexpect==0.2.post7 Fabric==1.8.0