pysftp / paramiko problem

Robin Becker robin at reportlab.com
Wed Jun 12 03:05:05 EDT 2019


On 12/06/2019 05:59, dieter wrote:
> Robin Becker <robin at reportlab.com> writes:
>> 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'))
> 
>  From the "sftp" documentation:
> 
>   |  normalize(self, remotepath)
>   |      Return the expanded path, w.r.t the server, of a given path.  This
>   |      can be used to resolve symlinks or determine what the server believes
>   |      to be the :attr:`.pwd`, by passing '.' as remotepath.
> 
> This suggests that your observation could be explained
> by "u'XXXX'" being a broken symlink.
> 
Well with real sftp I can cd to that path so if it is a symlink it goes somewhere.

With pysftp I am unable to chdir or cd into it. With a bit of difficulty I can use subprocess + sshpass + sftp to do the required 
transfer.
-- 
Robin Becker




More information about the Python-list mailing list