Changeset bd8fef3 in rtems-source-builder


Ignore:
Timestamp:
Feb 1, 2013, 1:35:59 AM (7 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, 4.9, master
Children:
3142708
Parents:
d34a0a9
Message:

Improve mkdir and rmdir.

Testing on various hosts shows a few problems. These changes seem
to help resolve them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source-builder/sb/build.py

    rd34a0a9 rbd8fef3  
    4444#
    4545version = '0.1'
     46
     47def removeall(path):
     48
     49    def _onerror(function, path, excinfo):
     50        print 'removeall error: (%r) %s' % (function, path)
     51
     52    shutil.rmtree(path, onerror = _onerror)
     53    return
    4654
    4755def _notice(opts, text):
     
    108116        if not self.opts.dry_run():
    109117            if path.exists(rmpath):
    110                 try:
    111                     shutil.rmtree(path.host(rmpath))
    112                 except IOError, err:
    113                     raise error.error('error removing: %s' % (rmpath))
    114                 except WindowsError, err:
    115                     _notice(self.opts, 'warning: cannot remove: %s' % (rmpath))
     118                removeall(rmpath)
    116119
    117120    def mkdir(self, mkpath):
    118121        self._output('making dir: %s' % (path.host(mkpath)))
    119122        if not self.opts.dry_run():
    120             try:
    121                 os.makedirs(path.host(mkpath))
    122             except IOError, err:
    123                 _notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
    124             except WindowsError, err:
    125                 _notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
     123            if os.name == 'nt':
     124                try:
     125                    os.makedirs(path.host(mkpath))
     126                except IOError, err:
     127                    _notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
     128                except OSError, err:
     129                    _notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
     130                except WindowsError, err:
     131                    _notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
     132            else:
     133                try:
     134                    os.makedirs(path.host(mkpath))
     135                except IOError, err:
     136                    _notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
     137                except OSError, err:
     138                    _notice(self.opts, 'warning: cannot make directory: %s' % (mkpath))
    126139
    127140    def get_file(self, url, local):
Note: See TracChangeset for help on using the changeset viewer.