Example #1
0
 def _rmtree_inner(path):
     from test.support import _force_run
     for name in _force_run(path, os.listdir, path):
         fullname = os.path.join(path, name)
         try:
             mode = os.lstat(fullname).st_mode
         except OSError:
             mode = 0
         if stat.S_ISDIR(mode):
             _rmtree_inner(fullname)
             _force_run(path, os.rmdir, fullname)
         else:
             _force_run(path, os.unlink, fullname)
Example #2
0
 def _rmtree_inner(path):
     for name in _force_run(path, os.listdir, path):
         fullname = os.path.join(path, name)
         try:
             mode = os.lstat(fullname).st_mode
         except OSError as exc:
             print("os_helper.rmtree(): os.lstat(%r) failed with %s"
                   % (fullname, exc),
                   file=sys.__stderr__)
             mode = 0
         if stat.S_ISDIR(mode):
             _waitfor(_rmtree_inner, fullname, waitall=True)
             _force_run(fullname, os.rmdir, fullname)
         else:
             _force_run(fullname, os.unlink, fullname)
Example #3
0
    def _rmtree(path):
        # XXX RUSTPYTHON: on ci, rmdir() raises PermissionError when target doesn't exist.
        # Might also happen locally, but not sure
        if not os.path.exists(path):
            return
        from test.support import _force_run

        def _rmtree_inner(path):
            for name in _force_run(path, os.listdir, path):
                fullname = os.path.join(path, name)
                try:
                    mode = os.lstat(fullname).st_mode
                except OSError as exc:
                    print("os_helper.rmtree(): os.lstat(%r) failed with %s"
                          % (fullname, exc),
                          file=sys.__stderr__)
                    mode = 0
                if stat.S_ISDIR(mode):
                    _waitfor(_rmtree_inner, fullname, waitall=True)
                    _force_run(fullname, os.rmdir, fullname)
                else:
                    _force_run(fullname, os.unlink, fullname)
        _waitfor(_rmtree_inner, path, waitall=True)
        _waitfor(lambda p: _force_run(p, os.rmdir, p), path)