Пример #1
0
def serve(cube: List[str], address: str, port: int, prefix: str, name: str,
          update_period: float, styles: str, config: str, tile_cache_size: str,
          tile_comp_mode: int, show: bool, verbose: bool, trace_perf: bool,
          aws_prof: str, aws_env: bool):
    """
    Serve data cubes via web service.

    Serves data cubes by a RESTful API and a OGC WMTS 1.0 RESTful and KVP interface.
    The RESTful API documentation can be found at https://app.swaggerhub.com/apis/bcdev/xcube-server.
    """

    from xcube.cli.common import parse_cli_kwargs
    import os.path

    prefix = prefix or name

    if config and cube:
        raise click.ClickException(
            "CONFIG and CUBES cannot be used at the same time.")
    if styles:
        styles = parse_cli_kwargs(styles, "STYLES")
    if (aws_prof or aws_env) and not cube:
        raise click.ClickException(
            "AWS credentials are only valid in combination with given CUBE argument(s)."
        )

    from xcube.version import version
    from xcube.webapi.defaults import SERVER_NAME, SERVER_DESCRIPTION
    print(f'{SERVER_NAME}: {SERVER_DESCRIPTION}, version {version}')

    if show:
        _run_viewer()

    from xcube.webapi.app import new_application
    from xcube.webapi.service import Service
    service = Service(new_application(
        prefix,
        os.path.dirname(config) if config else '.'),
                      prefix=prefix,
                      port=port,
                      address=address,
                      cube_paths=cube,
                      styles=styles,
                      config_file=config,
                      tile_cache_size=tile_cache_size,
                      tile_comp_mode=tile_comp_mode,
                      update_period=update_period,
                      log_to_stderr=verbose,
                      trace_perf=trace_perf,
                      aws_prof=aws_prof,
                      aws_env=aws_env)
    service.start()

    return 0
Пример #2
0
def serve(cubes: List[str], address: str, port: int, prefix: str, name: str,
          update: float, styles: str, config: str, tilecache: str,
          tilemode: int, show: bool, verbose: bool, traceperf: bool):
    """
    Serve data cubes via web service.

    Serves data cubes by a RESTful API and a OGC WMTS 1.0 RESTful and KVP interface.
    The RESTful API documentation can be found at https://app.swaggerhub.com/apis/bcdev/xcube-server.
    """

    from xcube.util.cliutil import parse_cli_kwargs

    prefix = prefix or name

    if config and cubes:
        raise click.ClickException(
            "CONFIG and CUBES cannot be used at the same time.")
    if styles:
        styles = parse_cli_kwargs(styles, "STYLES")

    from xcube.version import version
    from xcube.webapi.defaults import SERVER_NAME, SERVER_DESCRIPTION
    print(f'{SERVER_NAME}: {SERVER_DESCRIPTION}, version {version}')

    if show:
        _run_viewer()

    from xcube.webapi.app import new_application
    from xcube.webapi.service import Service
    service = Service(new_application(prefix),
                      prefix=prefix,
                      port=port,
                      address=address,
                      cube_paths=cubes,
                      styles=styles,
                      config_file=config,
                      tile_cache_size=tilecache,
                      tile_comp_mode=tilemode,
                      update_period=update,
                      log_to_stderr=verbose,
                      trace_perf=traceperf)

    service.start()
    return 0
Пример #3
0
 def get_app(self):
     application = new_application()
     application.service_context = CTX
     return application
Пример #4
0
def serve(cube: List[str], address: str, port: int, prefix: str,
          reverse_prefix: str, update_period: float, styles: str,
          config_file: str, base_dir: str, tile_cache_size: str,
          tile_comp_mode: int, show: bool, verbose: bool, trace_perf: bool,
          aws_prof: str, aws_env: bool):
    """
    Serve data cubes via web service.

    Serves data cubes by a RESTful API and a OGC WMTS 1.0 RESTful and KVP interface.
    The RESTful API documentation can be found at https://app.swaggerhub.com/apis/bcdev/xcube-server.
    """

    from xcube.cli.common import parse_cli_kwargs
    import os.path

    if config_file and cube:
        raise click.ClickException(
            "CONFIG and CUBES cannot be used at the same time.")
    if not config_file and not cube:
        config_file = os.environ.get(CONFIG_ENV_VAR)
    if styles:
        styles = parse_cli_kwargs(styles, "STYLES")
    if (aws_prof or aws_env) and not cube:
        raise click.ClickException(
            "AWS credentials are only valid in combination with given CUBE argument(s)."
        )
    if config_file and not os.path.isfile(config_file):
        raise click.ClickException(
            f"Configuration file not found: {config_file}")

    base_dir = base_dir or os.environ.get(
        BASE_ENV_VAR, config_file and os.path.dirname(config_file)) or '.'
    if not os.path.isdir(base_dir):
        raise click.ClickException(f"Base directory not found: {base_dir}")

    from xcube.version import version
    from xcube.webapi.defaults import SERVER_NAME, SERVER_DESCRIPTION
    print(f'{SERVER_NAME}: {SERVER_DESCRIPTION}, version {version}')

    if show:
        _run_viewer()

    from xcube.webapi.app import new_application
    application = new_application(route_prefix=prefix, base_dir=base_dir)

    from xcube.webapi.service import Service
    service = Service(application,
                      prefix=reverse_prefix or prefix,
                      port=port,
                      address=address,
                      cube_paths=cube,
                      styles=styles,
                      config_file=config_file,
                      base_dir=base_dir,
                      tile_cache_size=tile_cache_size,
                      tile_comp_mode=tile_comp_mode,
                      update_period=update_period,
                      log_to_stderr=verbose,
                      trace_perf=trace_perf,
                      aws_prof=aws_prof,
                      aws_env=aws_env)
    service.start()

    return 0