コード例 #1
0
    def get_dispatcher(self):
        """Returns the Dispatcher.

    Returns:
      The Dispatcher instance.
    """
        return request_info._LocalFakeDispatcher()
コード例 #2
0
ファイル: php_cli.py プロジェクト: Kazade/NeHe-Website
  def get_dispatcher(self):
    """Returns the Dispatcher.

    Returns:
      The Dispatcher instance.
    """
    return request_info._LocalFakeDispatcher()
コード例 #3
0
    def _init_modules_stub(self, **_):
        """Initializes the modules stub based off of your current yaml files

        Implements solution from
        http://stackoverflow.com/questions/28166558/invalidmoduleerror-when-using-testbed-to-unit-test-google-app-engine
        """
        from google.appengine.api import request_info
        # edit all_versions per modules & versions thereof needing tests
        all_versions = {}  # {'default': [1], 'andsome': [2], 'others': [1]}
        def_versions = {}  # {m: all_versions[m][0] for m in all_versions}
        m2h = {
        }  # {m: {def_versions[m]: 'localhost:8080'} for m in def_versions}
        for module in self.configuration.modules:
            module_name = module._module_name or 'default'
            module_version = module._version or '1'
            all_versions[module_name] = [module_version]
            def_versions[module_name] = module_version
            m2h[module_name] = {module_version: 'localhost:8080'}

        request_info._local_dispatcher = request_info._LocalFakeDispatcher(
            module_names=list(all_versions),
            module_name_to_versions=all_versions,
            module_name_to_default_versions=def_versions,
            module_name_to_version_to_hostname=m2h)
        self.testbed.init_modules_stub()
コード例 #4
0
def main():
    """Parses command line options and launches the API server."""
    shutdown.install_signal_handlers()

    options = PARSER.parse_args()
    logging.getLogger().setLevel(constants.LOG_LEVEL_TO_PYTHON_CONSTANT[
        options.dev_appserver_log_level])

    # Parse the application configuration if config_paths are provided, else
    # provide sensible defaults.
    if options.config_paths:
        app_config = application_configuration.ApplicationConfiguration(
            options.config_paths, options.app_id)
        app_id = app_config.app_id
        app_root = app_config.modules[0].application_root
    else:
        app_id = (options.app_id_prefix + options.app_id
                  if options.app_id else DEFAULT_API_SERVER_APP_ID)
        app_root = tempfile.mkdtemp()
    util.setup_environ(app_id)

    # pylint: disable=protected-access
    if options.java_app_base_url:
        # If the user specified a java_app_base_url, then the actual app is running
        # via the classic Java SDK, so we use the appropriate dispatcher that will
        # send requests to the Java app rather than forward them internally to a
        # devappserver2 module.
        dispatcher = _LocalJavaAppDispatcher(
            java_app_base_url=options.java_app_base_url)
    else:
        # TODO: Rename LocalFakeDispatcher or re-implement for
        # api_server.py.
        dispatcher = request_info_lib._LocalFakeDispatcher()
    request_info = wsgi_request_info.WSGIRequestInfo(dispatcher)
    # pylint: enable=protected-access

    metrics_logger = metrics.GetMetricsLogger()
    metrics_logger.Start(
        options.google_analytics_client_id,
        user_agent=options.google_analytics_user_agent,
        support_datastore_emulator=options.support_datastore_emulator,
        category=metrics.API_SERVER_CATEGORY)

    # When Cloud Datastore Emulator is invoked from api_server, it should be in
    # test mode, which stores in memory.
    options.datastore_emulator_is_test_mode = True
    server = create_api_server(request_info=request_info,
                               storage_path=get_storage_path(
                                   options.storage_path, app_id),
                               options=options,
                               app_id=app_id,
                               app_root=app_root)

    try:
        server.start()
        shutdown.wait_until_shutdown()
    finally:
        metrics.GetMetricsLogger().Stop()
        server.quit()
コード例 #5
0
def main():
    """Parses command line options and launches the API server."""
    shutdown.install_signal_handlers()

    # Initialize logging early -- otherwise some library packages may
    # pre-empt our log formatting.  NOTE: the level is provisional; it may
    # be changed based on the --debug flag.
    logging.basicConfig(
        level=logging.INFO,
        format=
        '%(levelname)-8s %(asctime)s %(filename)s:%(lineno)s] %(message)s')

    options = cli_parser.create_command_line_parser(
        cli_parser.API_SERVER_CONFIGURATION).parse_args()
    logging.getLogger().setLevel(constants.LOG_LEVEL_TO_PYTHON_CONSTANT[
        options.dev_appserver_log_level])

    # Parse the application configuration if config_paths are provided, else
    # provide sensible defaults.
    if options.config_paths:
        app_config = application_configuration.ApplicationConfiguration(
            options.config_paths, options.app_id)
        app_id = app_config.app_id
        app_root = app_config.modules[0].application_root
    else:
        app_id = (options.app_id
                  if options.app_id else DEFAULT_API_SERVER_APP_ID)
        app_root = tempfile.mkdtemp()

    # pylint: disable=protected-access
    # TODO: Rename LocalFakeDispatcher or re-implement for api_server.py.
    request_info = wsgi_request_info.WSGIRequestInfo(
        request_info_lib._LocalFakeDispatcher())
    # pylint: enable=protected-access

    os.environ['APPLICATION_ID'] = app_id
    os.environ['APPNAME'] = app_id
    os.environ['NGINX_HOST'] = options.nginx_host

    def request_context(environ):
        return request_info.request(environ, None)

    server = create_api_server(request_info=request_info,
                               storage_path=get_storage_path(
                                   options.storage_path, app_id),
                               options=options,
                               app_id=app_id,
                               app_root=app_root,
                               request_context=request_context)

    if options.pidfile:
        with open(options.pidfile, 'w') as pidfile:
            pidfile.write(str(os.getpid()))

    try:
        server.start()
        shutdown.wait_until_shutdown()
    finally:
        server.quit()
コード例 #6
0
ファイル: api_server.py プロジェクト: jsa/gaesdk-python
def main():
  """Parses command line options and launches the API server."""
  shutdown.install_signal_handlers()

  options = PARSER.parse_args()
  logging.getLogger().setLevel(
      constants.LOG_LEVEL_TO_PYTHON_CONSTANT[options.dev_appserver_log_level])

  # Parse the application configuration if config_paths are provided, else
  # provide sensible defaults.
  if options.config_paths:
    app_config = application_configuration.ApplicationConfiguration(
        options.config_paths, options.app_id)
    app_id = app_config.app_id
    app_root = app_config.modules[0].application_root
  else:
    app_id = (options.app_id_prefix + options.app_id if
              options.app_id else DEFAULT_API_SERVER_APP_ID)
    app_root = tempfile.mkdtemp()
  util.setup_environ(app_id)

  # pylint: disable=protected-access
  if options.java_app_base_url:
    # If the user specified a java_app_base_url, then the actual app is running
    # via the classic Java SDK, so we use the appropriate dispatcher that will
    # send requests to the Java app rather than forward them internally to a
    # devappserver2 module.
    dispatcher = _LocalJavaAppDispatcher(
        java_app_base_url=options.java_app_base_url)
  else:
    # TODO: Rename LocalFakeDispatcher or re-implement for
    # api_server.py.
    dispatcher = request_info_lib._LocalFakeDispatcher()
  request_info = wsgi_request_info.WSGIRequestInfo(dispatcher)
  # pylint: enable=protected-access

  metrics_logger = metrics.GetMetricsLogger()
  metrics_logger.Start(
      options.google_analytics_client_id,
      user_agent=options.google_analytics_user_agent,
      support_datastore_emulator=options.support_datastore_emulator,
      category=metrics.API_SERVER_CATEGORY)

  # When Cloud Datastore Emulator is invoked from api_server, it should be in
  # test mode, which stores in memory.
  options.datastore_emulator_is_test_mode = True
  server = create_api_server(
      request_info=request_info,
      storage_path=get_storage_path(options.storage_path, app_id),
      options=options, app_id=app_id, app_root=app_root)

  try:
    server.start()
    shutdown.wait_until_shutdown()
  finally:
    metrics.GetMetricsLogger().Stop()
    server.quit()
コード例 #7
0
def main():
    """Parses command line options and launches the API server."""
    shutdown.install_signal_handlers()

    options = PARSER.parse_args()
    logging.getLogger().setLevel(constants.LOG_LEVEL_TO_PYTHON_CONSTANT[
        options.dev_appserver_log_level])

    # Parse the application configuration if config_paths are provided, else
    # provide sensible defaults.
    if options.config_paths:
        app_config = application_configuration.ApplicationConfiguration(
            options.config_paths, options.app_id)
        app_id = app_config.app_id
        app_root = app_config.modules[0].application_root
    else:
        app_id = (options.app_id_prefix + options.app_id
                  if options.app_id else DEFAULT_API_SERVER_APP_ID)
        app_root = tempfile.mkdtemp()
    util.setup_environ(app_id)

    # pylint: disable=protected-access
    if options.java_app_base_url:
        # If the user specified a java_app_base_url, then the actual app is running
        # via the classic Java SDK, so we use the appropriate dispatcher that will
        # send requests to the Java app rather than forward them internally to a
        # devappserver2 module.
        dispatcher = _LocalJavaAppDispatcher(
            java_app_base_url=options.java_app_base_url)
    else:
        # TODO: Rename LocalFakeDispatcher or re-implement for
        # api_server.py.
        dispatcher = request_info_lib._LocalFakeDispatcher()
    request_info = wsgi_request_info.WSGIRequestInfo(dispatcher)
    # pylint: enable=protected-access

    server = create_api_server(request_info=request_info,
                               storage_path=get_storage_path(
                                   options.storage_path, app_id),
                               options=options,
                               app_id=app_id,
                               app_root=app_root)

    try:
        server.start()
        shutdown.wait_until_shutdown()
    finally:
        server.quit()
コード例 #8
0
ファイル: api_server.py プロジェクト: venky6363/appscale
def main():
    """Parses command line options and launches the API server."""
    shutdown.install_signal_handlers()

    options = cli_parser.create_command_line_parser(
        cli_parser.API_SERVER_CONFIGURATION).parse_args()
    logging.getLogger().setLevel(constants.LOG_LEVEL_TO_PYTHON_CONSTANT[
        options.dev_appserver_log_level])

    # Parse the application configuration if config_paths are provided, else
    # provide sensible defaults.
    if options.config_paths:
        app_config = application_configuration.ApplicationConfiguration(
            options.config_paths, options.app_id)
        app_id = app_config.app_id
        app_root = app_config.modules[0].application_root
    else:
        app_id = (options.app_id
                  if options.app_id else DEFAULT_API_SERVER_APP_ID)
        app_root = tempfile.mkdtemp()

    # pylint: disable=protected-access
    # TODO: Rename LocalFakeDispatcher or re-implement for api_server.py.
    request_info = wsgi_request_info.WSGIRequestInfo(
        request_info_lib._LocalFakeDispatcher())
    # pylint: enable=protected-access

    os.environ['APPNAME'] = app_id
    os.environ['NGINX_HOST'] = options.nginx_host

    server = create_api_server(request_info=request_info,
                               storage_path=get_storage_path(
                                   options.storage_path, app_id),
                               options=options,
                               app_id=app_id,
                               app_root=app_root)

    try:
        server.start()
        shutdown.wait_until_shutdown()
    finally:
        server.quit()
コード例 #9
0
ファイル: api_server.py プロジェクト: obino/appscale
def main():
  """Parses command line options and launches the API server."""
  shutdown.install_signal_handlers()

  options = cli_parser.create_command_line_parser(
      cli_parser.API_SERVER_CONFIGURATION).parse_args()
  logging.getLogger().setLevel(
      constants.LOG_LEVEL_TO_PYTHON_CONSTANT[options.dev_appserver_log_level])

  # Parse the application configuration if config_paths are provided, else
  # provide sensible defaults.
  if options.config_paths:
    app_config = application_configuration.ApplicationConfiguration(
        options.config_paths, options.app_id)
    app_id = app_config.app_id
    app_root = app_config.modules[0].application_root
  else:
    app_id = (options.app_id if
              options.app_id else DEFAULT_API_SERVER_APP_ID)
    app_root = tempfile.mkdtemp()

  # pylint: disable=protected-access
  # TODO: Rename LocalFakeDispatcher or re-implement for api_server.py.
  request_info = wsgi_request_info.WSGIRequestInfo(
      request_info_lib._LocalFakeDispatcher())
  # pylint: enable=protected-access

  os.environ['APPNAME'] = app_id
  os.environ['NGINX_HOST'] = options.nginx_host

  server = create_api_server(
      request_info=request_info,
      storage_path=get_storage_path(options.storage_path, app_id),
      options=options, app_id=app_id, app_root=app_root)

  try:
    server.start()
    shutdown.wait_until_shutdown()
  finally:
    server.quit()
コード例 #10
0
ファイル: nosegae.py プロジェクト: georgeteo/samsu-assasins
    def _init_modules_stub(self, **_):
        """Initializes the modules stub based off of your current yaml files

        Implements solution from
        http://stackoverflow.com/questions/28166558/invalidmoduleerror-when-using-testbed-to-unit-test-google-app-engine
        """
        from google.appengine.api import request_info
        # edit all_versions per modules & versions thereof needing tests
        all_versions = {}  # {'default': [1], 'andsome': [2], 'others': [1]}
        def_versions = {}  # {m: all_versions[m][0] for m in all_versions}
        m2h = {}  # {m: {def_versions[m]: 'localhost:8080'} for m in def_versions}
        for module in self.configuration.modules:
            module_name = module._module_name or 'default'
            module_version = module._version or '1'
            all_versions[module_name] = [module_version]
            def_versions[module_name] = module_version
            m2h[module_name] = {module_version: 'localhost:8080'}

        request_info._local_dispatcher = request_info._LocalFakeDispatcher(
            module_names=list(all_versions),
            module_name_to_versions=all_versions,
            module_name_to_default_versions=def_versions,
            module_name_to_version_to_hostname=m2h)
        self.testbed.init_modules_stub()