Example #1
0
def check_for_updates(application_configuration):
  """Checks for updates to the SDK.

  A message will be printed on stdout if the SDK is not up-to-date.

  Args:
    application_configuration: The
        application_configuration.ApplicationConfiguration for the application.
        Used to check if the api_versions used by the servers are supported by
        the SDK.

  Raises:
    SystemExit: if the api_version used by a server is not supported by the
        SDK.
  """
  update_server = appengine_rpc.HttpRpcServer(
      _UPDATE_SERVER,
      lambda: ('unused_email', 'unused_password'),
      _get_user_agent(),
      _get_source_name())  # TODO: is the source name arg necessary?
  # Don't try to talk to ClientLogin.
  update_server.authenticated = True

  # TODO: Update check needs to be refactored so the api_version for
  # all runtimes can be checked without generating duplicate nag messages.
  if application_configuration.servers:
    update_check = sdk_update_checker.SDKUpdateChecker(
        update_server, application_configuration.servers)
    update_check.CheckSupportedVersion()  # Can raise SystemExit.
    if update_check.AllowedToCheckForUpdates():
      update_check.CheckForUpdates()
Example #2
0
    def test_update_check_forbidden(self):
        module1 = object()
        module2 = object()
        self.config.modules = [module1, module2]

        sdk_update_checker.SDKUpdateChecker(
            mox.IgnoreArg(), self.config.modules).AndReturn(self.update_check)
        self.update_check.CheckSupportedVersion()
        self.update_check.AllowedToCheckForUpdates().AndReturn(False)

        self.mox.ReplayAll()
        update_checker.check_for_updates(self.config)
        self.mox.VerifyAll()
Example #3
0
    def test_update_check_allowed(self):
        server1 = object()
        server2 = object()
        self.config.servers = [server1, server2]

        sdk_update_checker.SDKUpdateChecker(
            mox.IgnoreArg(), self.config.servers).AndReturn(self.update_check)
        self.update_check.CheckSupportedVersion()
        self.update_check.AllowedToCheckForUpdates().AndReturn(True)
        self.update_check.CheckForUpdates()

        self.mox.ReplayAll()
        update_checker.check_for_updates(self.config)
        self.mox.VerifyAll()
Example #4
0
  port = option_dict[ARG_PORT]
  login_url = option_dict[ARG_LOGIN_URL]
  address = option_dict[ARG_ADDRESS]
  allow_skipped_files = option_dict[ARG_ALLOW_SKIPPED_FILES]
  static_caching = option_dict[ARG_STATIC_CACHING]
  skip_sdk_update_check = option_dict[ARG_SKIP_SDK_UPDATE_CHECK]
  interactive_console = option_dict[ARG_CONSOLE]

  if (option_dict[ARG_ADMIN_CONSOLE_SERVER] != '' and
      not dev_process.IsSubprocess()):

    server = MakeRpcServer(option_dict)
    if skip_sdk_update_check:
      logging.info('Skipping update check.')
    else:
      update_check = sdk_update_checker.SDKUpdateChecker(server, appinfo)
      update_check.CheckSupportedVersion()
      if update_check.AllowedToCheckForUpdates():
        update_check.CheckForUpdates()

  if dev_process.IsSubprocess():
    logging.getLogger().setLevel(logging.WARNING)

  try:
    dev_appserver.SetupStubs(appinfo.application,
                             _use_atexit_for_datastore_stub=True,
                             **option_dict)
  except:
    exc_type, exc_value, exc_traceback = sys.exc_info()
    logging.error(str(exc_type) + ': ' + str(exc_value))
    logging.debug(''.join(traceback.format_exception(