mirror of
https://git.rtems.org/rtems-source-builder
synced 2024-10-09 07:15:10 +08:00
Improve mkdir and rmdir.
Testing on various hosts shows a few problems. These changes seem to help resolve them.
This commit is contained in:
parent
d34a0a9b7f
commit
bd8fef3767
@ -44,6 +44,14 @@ import path
|
|||||||
#
|
#
|
||||||
version = '0.1'
|
version = '0.1'
|
||||||
|
|
||||||
|
def removeall(path):
|
||||||
|
|
||||||
|
def _onerror(function, path, excinfo):
|
||||||
|
print 'removeall error: (%r) %s' % (function, path)
|
||||||
|
|
||||||
|
shutil.rmtree(path, onerror = _onerror)
|
||||||
|
return
|
||||||
|
|
||||||
def _notice(opts, text):
|
def _notice(opts, text):
|
||||||
if not opts.quiet() and not log.default.has_stdout():
|
if not opts.quiet() and not log.default.has_stdout():
|
||||||
print text
|
print text
|
||||||
@ -107,22 +115,27 @@ class build:
|
|||||||
self._output('removing: %s' % (path.host(rmpath)))
|
self._output('removing: %s' % (path.host(rmpath)))
|
||||||
if not self.opts.dry_run():
|
if not self.opts.dry_run():
|
||||||
if path.exists(rmpath):
|
if path.exists(rmpath):
|
||||||
try:
|
removeall(rmpath)
|
||||||
shutil.rmtree(path.host(rmpath))
|
|
||||||
except IOError, err:
|
|
||||||
raise error.error('error removing: %s' % (rmpath))
|
|
||||||
except WindowsError, err:
|
|
||||||
_notice(self.opts, 'warning: cannot remove: %s' % (rmpath))
|
|
||||||
|
|
||||||
def mkdir(self, mkpath):
|
def mkdir(self, mkpath):
|
||||||
self._output('making dir: %s' % (path.host(mkpath)))
|
self._output('making dir: %s' % (path.host(mkpath)))
|
||||||
if not self.opts.dry_run():
|
if not self.opts.dry_run():
|
||||||
|
if os.name == 'nt':
|
||||||
try:
|
try:
|
||||||
os.makedirs(path.host(mkpath))
|
os.makedirs(path.host(mkpath))
|
||||||
except IOError, err:
|
except IOError, err:
|
||||||
_notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
|
_notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
|
||||||
|
except OSError, err:
|
||||||
|
_notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
|
||||||
except WindowsError, err:
|
except WindowsError, err:
|
||||||
_notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
|
_notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
os.makedirs(path.host(mkpath))
|
||||||
|
except IOError, err:
|
||||||
|
_notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
|
||||||
|
except OSError, err:
|
||||||
|
_notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
|
||||||
|
|
||||||
def get_file(self, url, local):
|
def get_file(self, url, local):
|
||||||
if local is None:
|
if local is None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user