JasperVanDenBosch / fexpect

extension for fabric to handle prompts through pexpect
http://ilogue.com/jasper/blog/fexpect--dealing-with-prompts-in-fabric-with-pexpect/
BSD 2-Clause "Simplified" License
44 stars 13 forks source link

Fexpect breaks fabric #17

Open keshavagrawal89 opened 10 years ago

keshavagrawal89 commented 10 years ago

I don't know if its happening only with me or anybody else is also facing the same issue.

The moment I import this package

from ilogue.fexpect import expect, expecting, run

in my fabfile the script stops running with the following error:

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

Versions used: fexpect==0.2.post7 Fabric==1.8.0

JasperVanDenBosch commented 10 years ago

That import statement overrides the regular fabric keywords such as run(). If you have not previously specified any expectations, the fexpect-wrapped run() cannot find them. You could change the import statement to something like:

from ilogue.fexpect import erun

This way the two versions do not get confused