Python 2.7 fabric/paramiko 远程解压文件时 EOF 错误

1 投票
1 回答
833 浏览
提问于 2025-04-16 11:19

我正在尝试使用fabric 0.92远程解压一个文件,但收到了paramiko的EOF错误。

def deployFile(self, localdir, remoteroot, filename):
    log.info('Deploying file {0} to host {1}...'.format(filename, self.host))
    env.password = self.password
    env.disable_known_hosts = True
    localFile=localdir+"/"+filename
    remoteFile='/tmp/{0}'.format(filename)

    with settings(host_string = self.connectstring):
        log.info('...putting {0}'.format(filename))
        put(localFile, "/tmp/", mode=0755)
        with cd(remoteroot):
            untar='tar zxvf {0}'.format(remoteFile)
            log.info('...untarring {0}'.format(filename))
            #paramiko.util.log_to_file('paramiko.out')
            sudo(untar, pty=True)

这是我从paramiko.out得到的输出:

DEB [20110205-20:49:36.782] thr=1   paramiko.transport: [chan 8] Max packet in: 34816 bytes
DEB [20110205-20:49:36.784] thr=2   paramiko.transport: [chan 7] EOF received (7)
DEB [20110205-20:49:36.785] thr=2   paramiko.transport: [chan 8] Max packet out: 32768 bytes
INF [20110205-20:49:36.785] thr=2   paramiko.transport: Secsh channel 8 opened.
DEB [20110205-20:49:36.788] thr=2   paramiko.transport: EOF in transport thread

我可以使用fabric执行其他的sudo命令,但解压文件似乎总是出问题。我对本地文件和远程文件的md5sum进行了比较,结果是一样的。当我登录到远程机器时,可以顺利解压文件,没有任何错误。

1 个回答

0

你在新的Fabric版本中还有这个问题吗?另外,你可以试着去掉tar命令中的详细输出选项。这样可能会减少对标准输出和标准输入的干扰。

撰写回答