| Index: client/third_party/infra_libs/utils.py
|
| diff --git a/client/third_party/infra_libs/utils.py b/client/third_party/infra_libs/utils.py
|
| index 8c49d3e7cff5fb6840e8d6103562abe4b0cd24ae..c975c5fef2500670e3e136eb1a24f8104838404c 100644
|
| --- a/client/third_party/infra_libs/utils.py
|
| +++ b/client/third_party/infra_libs/utils.py
|
| @@ -75,14 +75,27 @@ def rmtree(file_path): # pragma: no cover
|
| if not os.path.exists(file_path):
|
| return
|
|
|
| + if os.path.isfile(file_path):
|
| + for i in xrange(3):
|
| + try:
|
| + os.remove(file_path)
|
| + return
|
| + except OSError:
|
| + if i == 2:
|
| + raise
|
| + time.sleep(3)
|
| +
|
| if sys.platform == 'win32':
|
| # Give up and use cmd.exe's rd command.
|
| file_path = os.path.normcase(file_path)
|
| - for _ in xrange(3):
|
| - if not subprocess.call(['cmd.exe', '/c', 'rd', '/q', '/s', file_path]):
|
| - break
|
| - time.sleep(3)
|
| - return
|
| + for i in xrange(3):
|
| + try:
|
| + subprocess.check_call(['cmd.exe', '/c', 'rd', '/q', '/s', file_path])
|
| + return
|
| + except subprocess.CalledProcessError:
|
| + if i == 2:
|
| + raise
|
| + time.sleep(3)
|
|
|
| def remove_with_retry(rmfunc, path):
|
| if os.path.islink(path):
|
|
|