'Put' in SFTP using PAramiko

大兔子大兔子 提交于 2019-11-29 05:27:05

The solution seemed very funny to me!

source= '/Unzip.sh' 
destination ='/var/mpx/www/http/Unzip.sh'

Just modified the destination path to include the file name as well. Didn't expect some error like this coming from a Python package.

This also occurs in 2.0.2 when you try to sftp.mkdir('/exists'):

Traceback (most recent call last):
  ...
  File "/usr/local/lib/python2.7/site-packages/paramiko/sftp_client.py", line 380, in mkdir
    self._request(CMD_MKDIR, path, attr)
  File "/usr/local/lib/python2.7/site-packages/paramiko/sftp_client.py", line 730, in _request
    return self._read_response(num)
  File "/usr/local/lib/python2.7/site-packages/paramiko/sftp_client.py", line 781, in _read_response
    self._convert_status(msg)
  File "/usr/local/lib/python2.7/site-packages/paramiko/sftp_client.py", line 811, in _convert_status
    raise IOError(text)
IOError: Failure

This was my Python 2.7.9 fix:

try:
    sftp.mkdir(remote_dir)
except IOError:
    logging.debug('%s already exists.', remote_dir)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!