diff options
author | Amitay Isaacs <amitay@gmail.com> | 2011-08-02 16:13:01 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-08-03 14:26:07 +1000 |
commit | fb798d35df570d7cd9ad6386595dff9c5b0321e5 (patch) | |
tree | dafd497c376649e40f3ef5d9a184ddfff19c8bb7 /source4/scripting/python | |
parent | 65dcf82e644e8b57d3e09ad428a63a4708057311 (diff) | |
download | samba-fb798d35df570d7cd9ad6386595dff9c5b0321e5.tar.gz samba-fb798d35df570d7cd9ad6386595dff9c5b0321e5.tar.bz2 samba-fb798d35df570d7cd9ad6386595dff9c5b0321e5.zip |
samba-tool: Add functions to create directories and copy files over SMB share
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4/scripting/python')
-rw-r--r-- | source4/scripting/python/samba/netcmd/gpo.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/source4/scripting/python/samba/netcmd/gpo.py b/source4/scripting/python/samba/netcmd/gpo.py index 188cfe1453..c9765f2f20 100644 --- a/source4/scripting/python/samba/netcmd/gpo.py +++ b/source4/scripting/python/samba/netcmd/gpo.py @@ -202,6 +202,38 @@ def copy_directory_remote_to_local(conn, remotedir, localdir): file(l_name, 'w').write(data) +def copy_directory_local_to_remote(conn, localdir, remotedir): + if not conn.chkpath(remotedir): + conn.mkdir(remotedir) + l_dirs = [ localdir ] + r_dirs = [ remotedir ] + while l_dirs: + l_dir = l_dirs.pop() + r_dir = r_dirs.pop() + + dirlist = os.listdir(l_dir) + for e in dirlist: + l_name = os.path.join(l_dir, e) + r_name = r_dir + '\\' + e + + if os.path.isdir(l_name): + l_dirs.append(l_name) + r_dirs.append(r_name) + conn.mkdir(r_name) + else: + data = file(l_name, 'r').read() + conn.savefile(r_name, data) + + +def create_directory_hier(conn, remotedir): + elems = remotedir.replace('/', '\\').split('\\') + path = "" + for e in elems: + path = path + '\\' + e + if not conn.chkpath(path): + conn.mkdir(path) + + class cmd_listall(Command): """list all GPOs""" |