def copy_files(src, dst, uid, gid):
"""Copy files recursively and set uid and gid."""
for root, dirs, files in os.walk(src):
for name in dirs:
dst_root = root.replace(src, dst)
try:
logging.warning("%s|%s" % (dst_root, name))
logging.warning(os.path.join(root, name))
os.mkdir(os.path.join(dst_root, name))
os.chown(os.path.join(dst_root, name), uid, gid)
except OSError, e:
logging.warn(e)
for name in files:
dst_root = root.replace(src, dst)
try:
shutil.copyfile(os.path.join(root, name),
os.path.join(dst_root, name))
os.chown(os.path.join(dst_root, name), uid, gid)
except shutil.Error:
logging.warn(e)
评论列表
文章目录