One other benefit that I neglected to put into the previous post - I was able to maintain separate cwd's for each tree. An example of use: Each tree has its own context, independent of the context of python:
local, local2 = fs.LocalTree(), fs.LocalTree() local.pwd '/home/targoz' local2.pwd '/home/targoz' os.getcwd() '/home/targoz' local.chdir('..') local2.chdir('www') local.pwd '/home' local2.pwd '/home/targoz/www' os.getcwd() '/home/targoz'
Remote trees have the same interface:
remote_login_data = {'username': 'targoz', 'password': 'my_pass', host': 'hostname.com'} remote = fs.SSHTree(access=remote_login_data) remote.pwd() '/home/nportal'
Trees can interact, regardless of whether they are local or remote:
local2.listdir('files') ['myfile', 'otherfile.txt'] remote.listdir() [] localfile = local2.open(('targoz/myfile') # Opens a file-like object remote.savefile(localfile, 'remote_name') remote.listdir() ['myfile']