Python 结构-自动化标准输入
我知道,我总是想要更多 我想知道我怎样才能在布料上做到这样:Python 结构-自动化标准输入,python,django,fabric,Python,Django,Fabric,我知道,我总是想要更多 我想知道我怎样才能在布料上做到这样: def deploy(): local('git pull origin dev') gitusername = "test" gitpwd = "testpassword" # here render credentials to stdin so that no need to type in in console local('python manage.py collectstatic')
def deploy():
local('git pull origin dev')
gitusername = "test"
gitpwd = "testpassword"
# here render credentials to stdin so that no need to type in in console
local('python manage.py collectstatic')
confirm_type = "yes"
# here render 'confirm_type' to stdin so that I dont have to type in console
local('python manage.py migrate')
local('/etc/init.d/nginx restart')
我想到了fabric.operations.prompt
,但我不需要prompt。我希望fabric从变量中读取凭据,然后继续进行,而不询问我任何问题
有什么想法吗 如fabric中所述,用于通过stdin发送数据(使用来自“”的代码):
如果要查看输出,请删除stdout、stderr参数
此外,在collectstatic的情况下,您只需指定一个--noinput参数,而不必使用管道。看起来不错,让我测试一下
from subprocess import Popen, PIPE, STDOUT
p = Popen(['python', 'manage.py', 'collectstatic'], stdout=PIPE, stdin=PIPE, stderr=PIPE)
stdout_data = p.communicate(input='yes')[0]