Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Getpass错误_Python_Fabric - Fatal编程技术网

Python Getpass错误

Python Getpass错误,python,fabric,Python,Fabric,下面的fabric脚本是我需要使用的开源脚本,不幸的是我不熟悉这些东西。结构文件以以下内容开头: from fabric.api import * import time env.user = 'aegir' env.shell = '/bin/bash -c' # Download and import a platform using Drush Make def build_platform(site, profile, webserver, dbserver, makefile, b

下面的fabric脚本是我需要使用的开源脚本,不幸的是我不熟悉这些东西。结构文件以以下内容开头:

from fabric.api import *
import time

env.user = 'aegir'
env.shell = '/bin/bash -c'

# Download and import a platform using Drush Make
def build_platform(site, profile, webserver, dbserver, makefile, build):
  print "===> Building the platform..."
  run("drush make %s /var/aegir/platforms/%s" % (makefile, build))
Git推送触发新构建时,Jenkins服务器将运行结构文件。执行此文件时,第一个远程操作(最后一行)会导致以下错误

/usr/lib/python2.6/getpass.py:83: GetPassWarning: Can not control echo on the terminal.
  passwd = fallback_getpass(prompt, stream)
Warning: Password input may be echoed.
Password for aegir@o1.sub.aegir.local: ===> Building the platform...
[o1.sub.aegir.local] run: drush make https://raw.github.com/mig5/builds/master/mig5_platform.build /var/aegir/platforms/20121011010955
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/fabric/main.py", line 435, in main
    commands[name](*args, **kwargs)
  File "/usr/local/bin/fabfile.py", line 11, in build_platform
    run("drush make %s /var/aegir/platforms/%s" % (makefile, build))
  File "/usr/lib/pymodules/python2.6/fabric/network.py", line 390, in host_prompting_wrapper
    return func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/fabric/operations.py", line 414, in run
    channel = connections[env.host_string]._transport.open_session()
  File "/usr/lib/pymodules/python2.6/fabric/network.py", line 65, in __getitem__
    self[real_key] = connect(user, host, port)
  File "/usr/lib/pymodules/python2.6/fabric/network.py", line 219, in connect
    password = prompt_for_password(password, text)
  File "/usr/lib/pymodules/python2.6/fabric/network.py", line 279, in prompt_for_password
    new_password = getpass.getpass(password_prompt)
  File "/usr/lib/python2.6/getpass.py", line 83, in unix_getpass
    passwd = fallback_getpass(prompt, stream)
  File "/usr/lib/python2.6/getpass.py", line 118, in fallback_getpass
    return _raw_input(prompt, stream)
  File "/usr/lib/python2.6/getpass.py", line 135, in _raw_input
    raise EOFError
EOFError
Build step 'Execute shell' marked build as failure
Finished: FAILURE

我必须为aegir用户指定密码吗?我试图在
env.user='Aegir'
下包含
env.password='
(我用
passwd删除了远程机器上Aegir的用户密码——删除Aegir
),但这没有解决任何问题。

Ssh服务禁止没有密码的用户远程访问。您只需在计算机上和文件中为
aegir
用户设置密码。

需要登录。为了避免交互性,您可以从结构计算机复制公钥并粘贴到目标计算机的~/.ssh/authorized_密钥中

确保: 为了不包含或排除任何非键的内容(如引入换行),必须按原样复制键

这样做:

chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh/*

使用此功能和炸弹

output['running']=False#避免fabric在后台输出它正在做的事情
输出['stdout']=False#不显示stdout
输出['stderr']=False#不显示stderr
输出['status']=False#防止织物在某些情况下使用打印(至少在断开连接的情况下)
输出['warnings']=False#避免结构显示有关失败命令的消息
def run_it(命令、用户、主机、端口、密钥文件):
env.host_string=“%s@%s:%s”%(用户、主机、端口)
env.key_filename=keyfile
尝试:
res=run(命令,pty=False,shell=True)
打印“成功:返回\u代码=%s”%(返回\u代码)
除例外情况外,e:
打印“错误:%s”%(e)
标准输出,返回\u代码=无,无

return stdout,return_code
好的,这确实是问题所在。愚蠢的我没试过。谢谢如果上述所有操作都失败了怎么办?