summaryrefslogtreecommitdiffstats
path: root/scripts/cp-noerror
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/cp-noerror')
-rwxr-xr-xscripts/cp-noerror30
1 files changed, 29 insertions, 1 deletions
diff --git a/scripts/cp-noerror b/scripts/cp-noerror
index fdb3d2d19a..f0cd243586 100755
--- a/scripts/cp-noerror
+++ b/scripts/cp-noerror
@@ -5,10 +5,38 @@
5# 5#
6 6
7import sys 7import sys
8import os
8import shutil 9import shutil
9 10
11def copytree(src, dst, symlinks=False, ignore=None):
12 """Based on shutil.copytree"""
13 names = os.listdir(src)
14 try:
15 os.makedirs(dst)
16 except OSError:
17 # Already exists
18 pass
19 errors = []
20 for name in names:
21 srcname = os.path.join(src, name)
22 dstname = os.path.join(dst, name)
23 try:
24 shutil.copy2(srcname, dstname)
25 # catch the Error from the recursive copytree so that we can
26 # continue with other files
27 except shutil.Error, err:
28 errors.extend(err.args[0])
29 except EnvironmentError, why:
30 errors.append((srcname, dstname, str(why)))
31 try:
32 shutil.copystat(src, dst)
33 except OSError, why:
34 errors.extend((src, dst, str(why)))
35 if errors:
36 raise shutil.Error, errors
37
10try: 38try:
11 shutil.copytree(sys.argv[1], sys.argv[2]) 39 copytree(sys.argv[1], sys.argv[2])
12except shutil.Error: 40except shutil.Error:
13 pass 41 pass
14 42