I am trying to convert older code that uses ftplib as the endpoint has switched to sftp only.
I am using the pysftp wrapper around paramiko. The following script fails def main(): import pysftp with pysftp.Connection('ftp.remote.com', username='me', password='xxxxxx') as sftp: print('top level') print(sftp.listdir()) print(sftp.normalize(u'XXXX')) print('direct list of XXXX') print(sftp.listdir(u'XXXX')) with sftp.cd(u'XXXX'): print(sftp.listdir()) if __name__ == '__main__': main() when run the program prints [u'XXXX'] and then fails at the normalize command.
$ python tsftp.py top level [u'XXXX'] Traceback (most recent call last): File "tsftp.py", line 13, in <module> main() File "tsftp.py", line 6, in main print(sftp.normalize(u'XXXX')) File "/home/rptlab/devel/env/lib/python2.7/site-packages/pysftp/__init__.py", line 640, in normalize return self._sftp.normalize(remotepath) File "/home/rptlab/devel/env/lib/python2.7/site-packages/paramiko/sftp_client.py", line 632, in normalize t, msg = self._request(CMD_REALPATH, path) File "/home/rptlab/devel/env/lib/python2.7/site-packages/paramiko/sftp_client.py", line 813, in _request return self._read_response(num) File "/home/rptlab/devel/env/lib/python2.7/site-packages/paramiko/sftp_client.py", line 865, in _read_response self._convert_status(msg) File "/home/rptlab/devel/env/lib/python2.7/site-packages/paramiko/sftp_client.py", line 894, in _convert_status raise IOError(errno.ENOENT, text) IOError: [Errno 2] No such file.
I tried other commands, but it seems any attempt to cd to the XXXX directory fails. Using sftp in the shell directly I needed to add HostKeyAlgorithms=+ssh-dss for this host. Any pointers to what the problem could be? -- Robin Becker -- https://mail.python.org/mailman/listinfo/python-list