diff options
Diffstat (limited to '')
-rw-r--r-- | win/wb.py | 32 |
1 files changed, 31 insertions, 1 deletions
@@ -1,7 +1,7 @@ # Python module containing general build functions
# for OpenVPN on Windows
-import os, re, shutil
+import os, re, shutil, stat
autogen = "Automatically generated by OpenVPN Windows build system"
@@ -182,4 +182,34 @@ def cp(src, dest, dest_is_dir=True): print "COPY %s %s" % (src, dest)
shutil.copyfile(src, dest)
+def rm_rf(path):
+ try:
+ shutil.rmtree(path, onerror=onerror)
+ except:
+ pass
+
+def onerror(func, path, exc_info):
+ """
+ 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.
+
+ Usage : ``shutil.rmtree(path, onerror=onerror)``
+ """
+ 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 mkdir_silent(dir):
+ try:
+ os.mkdir(dir)
+ except:
+ pass
+
config = get_config()
|