Fabric正在给我一个EOFError。只有当我从之前运行结构的python脚本运行子进程时才会发生这种情况。
来自我的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')
如果我评论my_scripts/import_local.py
以下的行,我就不会收到任何错误:
p = subprocess.Popen(command.split(), stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
result = p.communicate()[0].splitlines()
if result:
print result
在剩下的子进程行中,我得到了这个回溯(用--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.
答案 0 :(得分:-1)
运行时会发生什么:
$ 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"'