Chromium Code Reviews| Index: native_client_sdk/src/build_tools/sdk_tools/sdk_update_common.py |
| diff --git a/native_client_sdk/src/build_tools/sdk_tools/sdk_update_common.py b/native_client_sdk/src/build_tools/sdk_tools/sdk_update_common.py |
| index ad4175ee748d5fb88ef2387780e0b5b792196e2c..e06ea1f8c09946ce4b2f58a798a44f4b1980a53a 100644 |
| --- a/native_client_sdk/src/build_tools/sdk_tools/sdk_update_common.py |
| +++ b/native_client_sdk/src/build_tools/sdk_tools/sdk_update_common.py |
| @@ -17,6 +17,14 @@ class Error(Exception): |
| pass |
| +def MakeDirs(directory): |
| + try: |
| + os.makedirs(directory) |
| + except OSError as e: |
| + if e.errno != errno.EEXIST: |
| + raise Error('Unable to make directory "%s".\n %s' % (directory, e)) |
| + |
|
Sam Clegg
2012/10/22 22:55:30
I'm still not completely sold on this pattern.
I
binji
2012/10/23 00:14:09
Fair enough, we use os.path.exists elsewhere -- ma
|
| + |
| def RemoveDir(outdir): |
| """Removes the given directory |
| @@ -30,18 +38,21 @@ def RemoveDir(outdir): |
| outdir: The directory to delete |
| Raises: |
| - CalledProcessError - if the delete operation fails on Windows |
| - OSError - if the delete operation fails on Linux |
| + Error - If this operation fails for any reason. |
| """ |
| try: |
| - shutil.rmtree(outdir) |
| - except OSError: |
| - if not os.path.exists(outdir): |
| - return |
| - # On Windows this could be an issue with junctions, so try again with rmdir |
| - if sys.platform == 'win32': |
| - subprocess.check_call(['rmdir', '/S', '/Q', outdir], shell=True) |
| + try: |
| + shutil.rmtree(outdir) |
| + except OSError: |
| + if not os.path.exists(outdir): |
| + return |
| + # On Windows this could be an issue with junctions, so try again with |
| + # rmdir |
| + if sys.platform == 'win32': |
| + subprocess.check_call(['rmdir', '/S', '/Q', outdir], shell=True) |
| + except Exception as e: |
| + raise Error('Unable to remove directory "%s"\n %s' % (outdir, e)) |
| def RenameDir(srcdir, destdir): |