def CheckForUpdates(self):
    """Queries the server for updates and nags the user if appropriate.

    Queries the server for the latest SDK version at the same time reporting
    the local SDK version.  The server will respond with a yaml document
    containing the fields:
      'release': The name of the release (e.g. 1.2).
      'timestamp': The time the release was created (YYYY-MM-DD HH:MM AM/PM TZ).
      'api_versions': A list of api_version strings (e.g. ['1', 'beta']).

    We will nag the user with increasing severity if:
    - There is a new release.
    - There is a new release with a new api_version.
    - There is a new release that does not support an api_version named in
      a configuration in self.configs.
    """
    version = self._ParseVersionFile()
    if version is None:
      logging.info('Skipping update check')
      return
    logging.info('Checking for updates to the SDK.')

    responses = {}



    try:
      for runtime in self.runtimes:
        responses[runtime] = yaml.safe_load(self.rpcserver.Send(
            '/api/updatecheck',
            timeout=UPDATE_CHECK_TIMEOUT,
            release=version['release'],
            timestamp=version['timestamp'],
            api_versions=version['api_versions'],
            runtime=runtime))
    except (urllib2.URLError, socket.error, ssl.SSLError), e:
      logging.info('Update check failed: %s', e)
      return



    try:
      latest = sorted(responses.values(), reverse=True,
                      key=lambda release: _VersionList(release['release']))[0]
    except ValueError:
      logging.warn('Could not parse this release version')

    if version['release'] == latest['release']:
      logging.info('The SDK is up to date.')
      return

    try:
      this_release = _VersionList(version['release'])
    except __HOLE__:
      logging.warn('Could not parse this release version (%r)',
                   version['release'])
    else:
      try:
        advertised_release = _VersionList(latest['release'])
      except ValueError:
        logging.warn('Could not parse advertised release version (%r)',
                     latest['release'])
      else:
        if this_release > advertised_release:
          logging.info('This SDK release is newer than the advertised release.')
          return

    for runtime, response in responses.items():
      api_versions = _GetSupportedApiVersions(response, runtime)
      obsolete_versions = sorted(
          self.runtime_to_api_version[runtime] - set(api_versions))
      if len(obsolete_versions) == 1:
        self._Nag(
            'The api version you are using (%s) is obsolete!  You should\n'
            'upgrade your SDK and test that your code works with the new\n'
            'api version.' % obsolete_versions[0],
            response, version, force=True)
      elif obsolete_versions:
        self._Nag(
            'The api versions you are using (%s) are obsolete!  You should\n'
            'upgrade your SDK and test that your code works with the new\n'
            'api version.' % obsolete_versions,
            response, version, force=True)

      deprecated_versions = sorted(
          self.runtime_to_api_version[runtime].intersection(api_versions[:-1]))
      if len(deprecated_versions) == 1:
        self._Nag(
            'The api version you are using (%s) is deprecated. You should\n'
            'upgrade your SDK to try the new functionality.' %
            deprecated_versions[0], response, version)
      elif deprecated_versions:
        self._Nag(
            'The api versions you are using (%s) are deprecated. You should\n'
            'upgrade your SDK to try the new functionality.' %
            deprecated_versions, response, version)

    self._Nag('There is a new release of the SDK available.',
              latest, version)
dataset/ETHPy150Open GoogleCloudPlatform/python-compat-runtime/appengine-compat/exported_appengine_sdk/google/appengine/tools/sdk_update_checker.py/SDKUpdateChecker.CheckForUpdates