sftpclone
sftpclone copied to clipboard
Error caused by slash directions on Windows
When I run the same clone method that works perfectly on Ubuntu Server 16 LTS system on a Windows PC, I get the following error:
2017-01-31 16:25:23,626 - DEBUG - [chan 0] lstat(b'/home/.../../static\\index.htm')
2017-01-31 16:25:23,702 - ERROR - Error while opening remote folder. Are you sure it does exist?
2017-01-31 16:25:23,703 - DEBUG - EOF in transport thread
On both systems, Python 3.5.1 is used.
It turns out the reason is that at Windows, paths both contain forward and backward slashes after os.path.join. I currently solve it by modifying path_join in sftpclone.py manually:
def path_join(*args):
"""
Wrapper around `os.path.join`.
Makes sure to join paths of the same type (bytes).
"""
args = (paramiko.py3compat.u(arg) for arg in args)
joined = os.path.join(*args)
joined = joined.replace("\\" , "/") #same slash direction for all path
return joined
Thanks for the report! :)
We actually never tried sftpclone
on Windows, so I'm glad it runs almost without issues.
As for this one, I'd prefer making all the slashes homogeneous by "construction" to account for additional (future) problems. For now, however, your solution fixes the issue, so thanks!
No prob, thanks for the fast response :)
When I run the same clone method that works perfectly on Ubuntu Server 16 LTS system on a Windows PC, I get the following error:
2017-01-31 16:25:23,626 - DEBUG - [chan 0] lstat(b'/home/.../../static\\index.htm') 2017-01-31 16:25:23,702 - ERROR - Error while opening remote folder. Are you sure it does exist? 2017-01-31 16:25:23,703 - DEBUG - EOF in transport thread
On both systems, Python 3.5.1 is used.
It turns out the reason is that at Windows, paths both contain forward and backward slashes after os.path.join. I currently solve it by modifying path_join in sftpclone.py manually:
def path_join(*args): """ Wrapper around `os.path.join`. Makes sure to join paths of the same type (bytes). """ args = (paramiko.py3compat.u(arg) for arg in args) joined = os.path.join(*args) joined = joined.replace("\\" , "/") #same slash direction for all path return joined
Hello, i am new to this community. Can you please share the script that's working on windows.
Source : windows PC Destination : Ubuntu server Thanks
@kramit912 you can find the modified code in this branch: https://github.com/fcivaner/sftpclone/tree/windows-path-fix
sftpclone.py: https://github.com/fcivaner/sftpclone/blob/windows-path-fix/sftpclone/sftpclone.py
@aldur I created a PR :) https://github.com/unbit/sftpclone/pull/38