diff options
author | simonhatch@chromium.org <simonhatch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-20 14:15:59 +0000 |
---|---|---|
committer | simonhatch@chromium.org <simonhatch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-20 14:15:59 +0000 |
commit | ad04625d03e519489873f2c7dd3749a5e99ab272 (patch) | |
tree | 5058f1029bcf38589a5b0daf351bc36a36be7329 /tools/bisect_utils.py | |
parent | 3b955fb63cfebc19ad5b7991c36daee4de876b65 (diff) | |
download | chromium_src-ad04625d03e519489873f2c7dd3749a5e99ab272.zip chromium_src-ad04625d03e519489873f2c7dd3749a5e99ab272.tar.gz chromium_src-ad04625d03e519489873f2c7dd3749a5e99ab272.tar.bz2 |
Getting an exception trying to delete the libjingle directory on windows due to read only files. If this happens, try to change permissions on the file and delete again.
BUG=266090
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/23068007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218481 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/bisect_utils.py')
-rw-r--r-- | tools/bisect_utils.py | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/tools/bisect_utils.py b/tools/bisect_utils.py index 511e971..5501ebc 100644 --- a/tools/bisect_utils.py +++ b/tools/bisect_utils.py @@ -9,6 +9,7 @@ used by the bisection scripts.""" import errno import os import shutil +import stat import subprocess import sys @@ -225,6 +226,30 @@ def RemoveThirdPartyWebkitDirectory(): return True +def OnAccessError(func, path, exc_info): + """ + Source: http://stackoverflow.com/questions/2656322/python-shutil-rmtree-fails-on-windows-with-access-is-denied + + Error handler for ``shutil.rmtree``. + + If the error is due to an access error (read only file) + it attempts to add write permission and then retries. + + If the error is for another reason it re-raises the error. + + Args: + func: The function that raised the error. + path: The path name passed to func. + exc_info: Exception information returned by sys.exc_info(). + """ + if not os.access(path, os.W_OK): + # Is the error an access error ? + os.chmod(path, stat.S_IWUSR) + func(path) + else: + raise + + def RemoveThirdPartyLibjingleDirectory(): """Removes third_party/libjingle. At some point, libjingle was causing issues syncing when using the git workflow (crbug.com/266324). @@ -232,11 +257,13 @@ def RemoveThirdPartyLibjingleDirectory(): Returns: True on success. """ + path_to_dir = os.path.join(os.getcwd(), 'third_party', 'libjingle') try: - path_to_dir = os.path.join(os.getcwd(), 'third_party', 'libjingle') if os.path.exists(path_to_dir): - shutil.rmtree(path_to_dir) + shutil.rmtree(path_to_dir, onerror=OnAccessError) except OSError, e: + print 'Error #%d while running shutil.rmtree(%s): %s' % ( + e.errno, path_to_dir, str(e)) if e.errno != errno.ENOENT: return False return True |