+def copy (src, dest):
+ if os.path.exists(dest) and os.path.isdir(dest):
+ dest_dir = dest;
+ else:
+ dest_dir = os.path.dirname(dest);
+ if not os.path.exists(dest_dir):
+ umask = os.umask(00000);
+ os.makedirs(dest_dir, 02775);
+ os.umask(umask);
+ #print "Copying %s to %s..." % (src, dest);
+ if os.path.exists(dest) and os.path.isdir(dest):
+ dest = dest + '/' + os.path.basename(src);
+ if os.path.exists(dest) and not os.access(dest, os.W_OK):
+ raise cant_overwrite_exc
+ shutil.copy2(src, dest);
+ os.chmod(dest, 0664);
+