def EnsureAuthenticated(self, force):
    'Best effort check that user is authenticated with Gerrit server.'
    if settings.GetGerritSkipEnsureAuthenticated():
        return
    if gerrit_util.GceAuthenticator.is_gce():
        return
    self.GetCodereviewServer()
    git_host = self._GetGitHost()
    assert (self._gerrit_server and self._gerrit_host)
    cookie_auth = gerrit_util.CookiesAuthenticator()
    gerrit_auth = cookie_auth.get_auth_header(self._gerrit_host)
    git_auth = cookie_auth.get_auth_header(git_host)
    if (gerrit_auth and git_auth):
        if (gerrit_auth == git_auth):
            return
        print(('WARNING: you have different credentials for Gerrit and git hosts.\n         Check your %s or %s file for credentials of hosts:\n           %s\n           %s\n         %s' % (cookie_auth.get_gitcookies_path(), cookie_auth.get_netrc_path(), git_host, self._gerrit_host, cookie_auth.get_new_password_message(git_host))))
        if (not force):
            ask_for_data('If you know what you are doing, press Enter to continue, Ctrl+C to abort.')
        return
    else:
        missing = ([] if gerrit_auth else (([self._gerrit_host] + []) if git_auth else [git_host]))
        DieWithError(('Credentials for the following hosts are required:\n  %s\nThese are read from %s (or legacy %s)\n%s' % ('\n  '.join(missing), cookie_auth.get_gitcookies_path(), cookie_auth.get_netrc_path(), cookie_auth.get_new_password_message(git_host))))
Best effort check that user is authenticated with Gerrit server.
def EnsureAuthenticated(self, force):
    
    if settings.GetGerritSkipEnsureAuthenticated():
        return
    if gerrit_util.GceAuthenticator.is_gce():
        return
    self.GetCodereviewServer()
    git_host = self._GetGitHost()
    assert (self._gerrit_server and self._gerrit_host)
    cookie_auth = gerrit_util.CookiesAuthenticator()
    gerrit_auth = cookie_auth.get_auth_header(self._gerrit_host)
    git_auth = cookie_auth.get_auth_header(git_host)
    if (gerrit_auth and git_auth):
        if (gerrit_auth == git_auth):
            return
        print(('WARNING: you have different credentials for Gerrit and git hosts.\n         Check your %s or %s file for credentials of hosts:\n           %s\n           %s\n         %s' % (cookie_auth.get_gitcookies_path(), cookie_auth.get_netrc_path(), git_host, self._gerrit_host, cookie_auth.get_new_password_message(git_host))))
        if (not force):
            ask_for_data('If you know what you are doing, press Enter to continue, Ctrl+C to abort.')
        return
    else:
        missing = ([] if gerrit_auth else (([self._gerrit_host] + []) if git_auth else [git_host]))
        DieWithError(('Credentials for the following hosts are required:\n  %s\nThese are read from %s (or legacy %s)\n%s' % ('\n  '.join(missing), cookie_auth.get_gitcookies_path(), cookie_auth.get_netrc_path(), cookie_auth.get_new_password_message(git_host))))