Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1191)

Unified Diff: native_client_sdk/src/build_tools/sdk_tools/sdk_update_common.py

Issue 11228013: [NaCl SDK] Refactor sdk_update*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tests pass Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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):

Powered by Google App Engine
This is Rietveld 408576698