+def copy (src, dest):
+ if os.path.exists(dest) and stat.S_ISDIR(os.stat(dest)[stat.ST_MODE]):
+ 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);
+ shutil.copy2(src, dest);
+ if os.path.exists(dest) and stat.S_ISDIR(os.stat(dest)[stat.ST_MODE]):
+ dest = dest + '/' + os.path.basename(src);
+ os.chmod(dest, 0664);
+