def rm_subdirs(path, onerror=None):
 names = []
 try:
  names = os.listdir(path)
 except os.error as err:
  if (onerror is not None):
   onerror(os.listdir, path, sys.exc_info())
  else:
   raise
 for name in names:
  fullname = os.path.join(path, name)
  if os.path.isdir(fullname):
   if (onerror is not None):
    shutil.rmtree(fullname, False, onerror)
   else:
    err_count = 0
    while True:
     try:
      shutil.rmtree(fullname, False, None)
      break
     except os.error:
      if (err_count > 0):
       raise
      err_count += 1
      time.sleep(RM_SUBDIRS_RETRY_TIME)

def rm_subdirs ( path , onerror = None ) : names = [ ] try : names = os . listdir ( path ) except os . error as err : if ( onerror is not None ) : onerror ( os . listdir , path , sys . exc_info ( ) ) else : raise for name in names : fullname = os . path . join ( path , name ) if os . path . isdir ( fullname ) : if ( onerror is not None ) : shutil . rmtree ( fullname , False , onerror ) else : err_count = 0 while True : try : shutil . rmtree ( fullname , False , None ) break except os . error : if ( err_count > 0 ) : raise err_count += 1 time . sleep ( RM_SUBDIRS_RETRY_TIME )
remove all subdirectories in this path .