I have written a small program that uses the os
module extensively especially os.walk
, os.remove
etc. For example,
def dump_folder(source, destination):
"""
"""
# uses os.walk, shutil.move
def encrypt_folder(folder, recipient):
"""
"""
# uses os.walk, os.remove
Now, I would like to extend this program to support SFTP
folders.
Do I need to mount the folders locally to make os.*
work? For example, in Windows, I could use win32net
and do something like:
try:
win32wnet.WNetAddConnection2(...drive, remote...)
except:
pass
If I am going to use a tool like paramiko
, can I make it work with the same code without worrying about the details which os.walk
, os.remove
, shutil.move
provides? If I can't, then I will have to rewrite the program quite a bit which is not something I want.
PS: The goal of this question is to find out how to use the same code to work with remote folders. Tools like paramiko
deals with implementation details (like where is the file etc) so we will have to re-write the program . The idea of mounting remote file locally and ability to use os
is really nice and powerful.