diff options
author | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
---|---|---|
committer | Tudor Florea <tudor.florea@enea.com> | 2014-10-16 03:05:19 +0200 |
commit | c527fd1f14c27855a37f2e8ac5346ce8d940ced2 (patch) | |
tree | bb002c1fdf011c41dbd2f0927bed23ecb5f83c97 /scripts/cp-noerror | |
download | poky-c527fd1f14c27855a37f2e8ac5346ce8d940ced2.tar.gz |
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch
Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'scripts/cp-noerror')
-rwxr-xr-x | scripts/cp-noerror | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/scripts/cp-noerror b/scripts/cp-noerror new file mode 100755 index 0000000000..28eb90d4a0 --- /dev/null +++ b/scripts/cp-noerror | |||
@@ -0,0 +1,52 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # | ||
3 | # Allow copying of $1 to $2 but if files in $1 disappear during the copy operation, | ||
4 | # don't error. | ||
5 | # Also don't error if $1 disappears. | ||
6 | # | ||
7 | |||
8 | import sys | ||
9 | import os | ||
10 | import shutil | ||
11 | |||
12 | def copytree(src, dst, symlinks=False, ignore=None): | ||
13 | """Based on shutil.copytree""" | ||
14 | names = os.listdir(src) | ||
15 | try: | ||
16 | os.makedirs(dst) | ||
17 | except OSError: | ||
18 | # Already exists | ||
19 | pass | ||
20 | errors = [] | ||
21 | for name in names: | ||
22 | srcname = os.path.join(src, name) | ||
23 | dstname = os.path.join(dst, name) | ||
24 | try: | ||
25 | d = dstname | ||
26 | if os.path.isdir(dstname): | ||
27 | d = os.path.join(dstname, os.path.basename(srcname)) | ||
28 | if os.path.exists(d): | ||
29 | continue | ||
30 | try: | ||
31 | os.link(srcname, dstname) | ||
32 | except OSError: | ||
33 | shutil.copy2(srcname, dstname) | ||
34 | # catch the Error from the recursive copytree so that we can | ||
35 | # continue with other files | ||
36 | except shutil.Error, err: | ||
37 | errors.extend(err.args[0]) | ||
38 | except EnvironmentError, why: | ||
39 | errors.append((srcname, dstname, str(why))) | ||
40 | try: | ||
41 | shutil.copystat(src, dst) | ||
42 | except OSError, why: | ||
43 | errors.extend((src, dst, str(why))) | ||
44 | if errors: | ||
45 | raise shutil.Error, errors | ||
46 | |||
47 | try: | ||
48 | copytree(sys.argv[1], sys.argv[2]) | ||
49 | except shutil.Error: | ||
50 | pass | ||
51 | except OSError: | ||
52 | pass | ||