summaryrefslogtreecommitdiffstats
path: root/native_client_sdk
diff options
context:
space:
mode:
authorelijahtaylor@google.com <elijahtaylor@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-21 18:57:07 +0000
committerelijahtaylor@google.com <elijahtaylor@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-21 18:57:07 +0000
commitea273285736ef4d01cf38b85b4fbc04e5b987e15 (patch)
tree75c01982da2618db76156452e07c20f1d3230979 /native_client_sdk
parent5009b7a456abbd6b83e3c1e455240a3d57f422d9 (diff)
downloadchromium_src-ea273285736ef4d01cf38b85b4fbc04e5b987e15.zip
chromium_src-ea273285736ef4d01cf38b85b4fbc04e5b987e15.tar.gz
chromium_src-ea273285736ef4d01cf38b85b4fbc04e5b987e15.tar.bz2
Make nacl_sdk oshelpers rm use glob to match patterns.
Also fix rm command for directories (would only delete one directory previously, and would return non-zero). This change only affects native_client_sdk BUG=none TEST=trybots Review URL: https://chromiumcodereview.appspot.com/9420035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122844 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rw-r--r--native_client_sdk/src/tools/oshelpers.py73
1 files changed, 37 insertions, 36 deletions
diff --git a/native_client_sdk/src/tools/oshelpers.py b/native_client_sdk/src/tools/oshelpers.py
index 9248a05..93648a9 100644
--- a/native_client_sdk/src/tools/oshelpers.py
+++ b/native_client_sdk/src/tools/oshelpers.py
@@ -249,45 +249,46 @@ def Remove(args):
parser.error('ERROR: expecting FILE...')
try:
- for dst in files:
- if options.verbose:
- print 'rm ' + dst
-
+ for pattern in files:
+ dst_files = glob.glob(pattern)
# Ignore non existing files when using force
- if not os.path.exists(dst) and options.force:
- print "rm: Skipping " + dst
+ if len(files) == 0 and options.force:
+ print "rm: Skipping " + pattern
continue
-
- if os.path.isfile(dst) or os.path.islink(dst):
- for i in range(5):
- try:
- # Check every time, since it may have been deleted after the
- # previsou failed attempt.
- if os.path.isfile(dst) or os.path.islink(dst):
- os.remove(dst)
- break
- except OSError as error:
- if i == 5:
- print 'Gave up.'
+ elif len(files) == 0:
+ raise OSError('rm: no such file or directory: ' + pattern)
+
+ for dst in dst_files:
+ if options.verbose:
+ print 'rm ' + dst
+
+ if os.path.isfile(dst) or os.path.islink(dst):
+ for i in range(5):
+ try:
+ # Check every time, since it may have been deleted after the
+ # previous failed attempt.
+ if os.path.isfile(dst) or os.path.islink(dst):
+ os.remove(dst)
+ break
+ except OSError as error:
+ if i == 5:
+ print 'Gave up.'
+ raise OSError('rm: ' + str(error))
+ print 'Failed remove with %s, retrying' % error
+ time.sleep(5)
+
+ if options.recursive:
+ for i in range(5):
+ try:
+ if os.path.isdir(dst):
+ shutil.rmtree(dst)
+ break
+ except OSError as error:
+ if i == 5:
+ print 'Gave up.'
raise OSError('rm: ' + str(error))
- print 'Failed remove with %s, retrying' % error
- time.sleep(5)
-
- if options.recursive:
- for i in range(5):
- try:
- if os.path.isdir(dst):
- shutil.rmtree(dst)
- break
- except OSError as error:
- if i == 5:
- print 'Gave up.'
- raise OSError('rm: ' + str(error))
- print 'Failed rmtree with %s, retrying' % error
- time.sleep(5)
-
- print 'rm: %s is a directory.' % dst
- return 1
+ print 'Failed rmtree with %s, retrying' % error
+ time.sleep(5)
except OSError as error:
print error