EOFError when running subprocess with fabric

Go To StackoverFlow.com

2

Fabric is giving me an EOFError when I try to chown a directory. It only happens if I run a subprocess from a python script that fabric runs immediately before.

From my fabfile:

...
with settings(warn_only=True):
    run('python my_scripts/import_local.py')
sudo('chown www-data:www-data /opt/mm/my_project/uploads -R')

If I comment the lines below out of my_scripts/import_local.py I get no error:

    p = subprocess.Popen(command.split(), stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)
    result = p.communicate()[0].splitlines()
    if result:
        print result

With the subprocess lines left in I get this traceback (running with --show=debug):

[xx.xx.xxx.xxx] sudo: sudo -S -p 'sudo password:'  /bin/bash -l -c "cd /opt/mm/my_project/current && source environment.sh && chown www-data:www-data /opt/mm/my_project/uploads -R"
Traceback (most recent call last):
  File "/Users/jesse.aldridge/.virtualenvs/my_project/lib/python2.6/site-packages/fabric/main.py", line 682, in main
    *args, **kwargs
  File "/Users/jesse.aldridge/.virtualenvs/my_project/lib/python2.6/site-packages/fabric/tasks.py", line 232, in execute
    task.run(*args, **new_kwargs)
  File "/Users/jesse.aldridge/.virtualenvs/my_project/lib/python2.6/site-packages/fabric/tasks.py", line 105, in run
    return self.wrapped(*args, **kwargs)
  File "/Users/jesse.aldridge/Dropbox/my_code/my_project/fabfile.py", line 162, in do_reimport
    sudo('chown www-data:www-data /opt/mm/my_project/uploads -R')
  File "/Users/jesse.aldridge/.virtualenvs/my_project/lib/python2.6/site-packages/fabric/network.py", line 343, in host_prompting_wrapper
    return func(*args, **kwargs)
  File "/Users/jesse.aldridge/.virtualenvs/my_project/lib/python2.6/site-packages/fabric/operations.py", line 976, in sudo
    user=user)
  File "/Users/jesse.aldridge/.virtualenvs/my_project/lib/python2.6/site-packages/fabric/operations.py", line 867, in _run_command
    combine_stderr)
  File "/Users/jesse.aldridge/.virtualenvs/my_project/lib/python2.6/site-packages/fabric/operations.py", line 753, in _execute
    channel.get_pty(width=cols, height=rows)
  File "/Users/jesse.aldridge/.virtualenvs/my_project/lib/python2.6/site-packages/ssh/channel.py", line 158, in get_pty
    self._wait_for_event()
  File "/Users/jesse.aldridge/.virtualenvs/my_project/lib/python2.6/site-packages/ssh/channel.py", line 1084, in _wait_for_event
    raise e
EOFError
Disconnecting from xx.xx.xxx.xxx... done.
2012-04-03 20:12
by Jesse Aldridge
looks like a problem with sudo. maybe this user needs a password to run sudo - Not_a_Golfer 2012-04-05 22:41
When I do a sudo elsewhere in the script, fabric prompts me for my password - Jesse Aldridge 2012-04-06 00:44
What happens if you do not use the subprocess PIPEs? Or if you put a little time.sleep in between the lines of your fabfile - Jasper van den Bosch 2012-04-22 18:08


-1

What happens when you run:

$ ssh xx.xx.xxx.xxx -t'sudo -S -p "sudo password:"  /bin/bash -l -c "cd /opt/mm/my_project/current && source environment.sh && chown www-data:www-data /opt/mm/my_project/uploads -R"'
2012-05-03 17:12
by Morgan
I have the same error, this command work - GuySoft 2014-10-22 11:43