diff options
author | Chris Johns <chrisj@rtems.org> | 2013-02-22 14:44:51 +1100 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2013-02-22 14:44:51 +1100 |
commit | ee47d7210e669c2bb2f9b5921a54ac5f369e80a2 (patch) | |
tree | 61b0466ffbbe490864d9b35c7b464e907b2b17d7 /source-builder/sb/path.py | |
parent | Support directly installing. (diff) | |
download | rtems-source-builder-ee47d7210e669c2bb2f9b5921a54ac5f369e80a2.tar.bz2 |
Create tar directory when making build set tar files.
Move the mkdir and removeall code from the build module to the path
module.
Diffstat (limited to 'source-builder/sb/path.py')
-rw-r--r-- | source-builder/sb/path.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source-builder/sb/path.py b/source-builder/sb/path.py index eda6d50..1050eee 100644 --- a/source-builder/sb/path.py +++ b/source-builder/sb/path.py @@ -24,8 +24,11 @@ # import os +import shutil import string +import error + windows = os.name == 'nt' def host(path): @@ -81,6 +84,36 @@ def isfile(path): def isabspath(path): return path[0] == '/' +def mkdir(path): + if exists(path): + if not isdir(path): + raise error.general('path exists and is not a directory: %s' % (path)) + else: + if windows: + try: + os.makedirs(host(path)) + except IOError, err: + raise error.general('cannot make directory: %s' % (path)) + except OSError, err: + raise error.general('cannot make directory: %s' % (path)) + except WindowsError, err: + raise error.general('cannot make directory: %s' % (path)) + else: + try: + os.makedirs(host(path)) + except IOError, err: + raise error.general('cannot make directory: %s' % (path)) + except OSError, err: + raise error.general('cannot make directory: %s' % (path)) + +def removeall(path): + + def _onerror(function, path, excinfo): + print 'removeall error: (%r) %s' % (function, path) + + shutil.rmtree(path, onerror = _onerror) + return + if __name__ == '__main__': print host('/a/b/c/d-e-f') print host('//a/b//c/d-e-f') |