code: def ensure_berksfile_cookbooks_are_installed():
      
      msg = "Vendoring cookbooks from Berksfile {0} to directory {1}..."
      print(msg.format(env.berksfile, env.berksfile_cookbooks_directory))
  
      run_vendor = True
      cookbooks_dir = env.berksfile_cookbooks_directory
      berksfile_lock_path = cookbooks_dir+'/Berksfile.lock'
  
      berksfile_lock_exists = os.path.isfile(berksfile_lock_path)
      cookbooks_dir_exists = os.path.isdir(cookbooks_dir)
  
      if cookbooks_dir_exists and berksfile_lock_exists:
          berksfile_mtime = os.stat('Berksfile').st_mtime
          cookbooks_mtime = os.stat(berksfile_lock_path).st_mtime
          run_vendor = berksfile_mtime > cookbooks_mtime
  
      if run_vendor:
          if cookbooks_dir_exists:
              shutil.rmtree(env.berksfile_cookbooks_directory)
  
          p = subprocess.Popen(['berks', 'vendor', env.berksfile_cookbooks_directory],
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
          stdout, stderr = p.communicate()
          if env.verbose or p.returncode:
              print stdout, stderr
docs: Run 'berks vendor' to berksfile cookbooks directory