code: def remove_directory(directory, show_warnings=True):
      
      errors = []
  
      def onerror(function, path, excinfo):
          if show_warnings:
              print 'Cannot delete %s: %s' % (os.path.relpath(directory), excinfo[1])
          errors.append((function, path, excinfo))
  
      if os.path.exists(directory):
          if not os.path.isdir(directory):
              raise NotADirectoryError(directory)
          shutil.rmtree(directory, onerror=onerror)
  
      return errors
docs: Deletes a directory and its contents.
      Returns a list of errors in form (function, path, excinfo).