예제 #1
0
def cli(target_address, authenticate_with_google, ssl_root_cert_path,
        ssl_domain_name, use_insecure_channel, stream_name):
  """Playback a stream. The packet type must be convertible to a raw image."""
  playback_app_config = {
      "app_path":
          os.path.join(
              pathlib.Path(apps.__file__).parents[0], _PLAYBACK_APP_NAME),
      "target_address":
          util.normalize_string_for_commandline(target_address),
      "authenticate_with_google":
          util.to_cpp_bool_string(authenticate_with_google),
      "ssl_domain_name":
          util.normalize_string_for_commandline(ssl_domain_name),
      "ssl_root_cert_path":
          util.normalize_string_for_commandline(ssl_root_cert_path),
      "stream_name":
          util.normalize_string_for_commandline(stream_name),
      "use_insecure_channel":
          util.to_cpp_bool_string(use_insecure_channel),
  }

  playback_app_cmd = ("{app_path} "
                      "--target_address={target_address} "
                      "--authenticate_with_google={authenticate_with_google} "
                      "--ssl_root_cert_path={ssl_root_cert_path} "
                      "--ssl_domain_name={ssl_domain_name} "
                      "--stream_name={stream_name} "
                      "--use_insecure_channel={use_insecure_channel} ".format(
                          **playback_app_config))
  logging.debug("Executing command %s.", playback_app_cmd)

  playback_app_tokens = shlex.split(playback_app_cmd)
  os.execlp(playback_app_tokens[0], *playback_app_tokens)
예제 #2
0
def cli(target_address, ssl_root_cert_path, ssl_domain_name,
        authenticate_with_google, use_insecure_channel, stream_name,
        source_uri, loop, trace_probability):
    """Ingest a video source into a stream."""
    ingester_app_config = {
        "app_path":
        os.path.join(
            pathlib.Path(apps.__file__).parents[0], _INGESTION_APP_NAME),
        "target_address":
        util.normalize_string_for_commandline(target_address),
        "authenticate_with_google":
        util.to_cpp_bool_string(authenticate_with_google),
        "ssl_domain_name":
        util.normalize_string_for_commandline(ssl_domain_name),
        "ssl_root_cert_path":
        util.normalize_string_for_commandline(ssl_root_cert_path),
        "stream_name":
        util.normalize_string_for_commandline(stream_name),
        "loop":
        util.to_cpp_bool_string(loop),
        "source_uri":
        util.normalize_string_for_commandline(source_uri),
        "use_insecure_channel":
        util.to_cpp_bool_string(use_insecure_channel),
        "trace_probability":
        trace_probability,
    }

    ingester_app_cmd = (
        "{app_path} "
        "--target_address={target_address} "
        "--authenticate_with_google={authenticate_with_google} "
        "--ssl_root_cert_path={ssl_root_cert_path} "
        "--ssl_domain_name={ssl_domain_name} "
        "--stream_name={stream_name} "
        "--loop={loop} "
        "--source_uri={source_uri} "
        "--trace_probability={trace_probability} "
        "--use_insecure_channel={use_insecure_channel} ".format(
            **ingester_app_config))
    logging.debug("Executing command %s.", ingester_app_cmd)

    ingester_app_tokens = shlex.split(ingester_app_cmd)
    os.execlp(ingester_app_tokens[0], *ingester_app_tokens)
예제 #3
0
def _exec_manager_app(op_id, args):
    """Configure and execute the manager app for onprem clusters."""
    manager_app_config = {
        "app_path":
        os.path.join(
            pathlib.Path(apps.__file__).parents[0], _MANAGEMENT_APP_NAME),
        "op_id":
        op_id,
        "target_address":
        util.normalize_string_for_commandline(args["target_address"]),
        "ssl_domain_name":
        util.normalize_string_for_commandline(args["ssl_domain_name"]),
        "ssl_root_cert_path":
        util.normalize_string_for_commandline(args["ssl_root_cert_path"]),
        "use_google_managed_service":
        util.to_cpp_bool_string(False),
        "use_insecure_channel":
        util.to_cpp_bool_string(args["use_insecure_channel"]),
    }
    manager_app_tpl = (
        "{app_path} "
        "--op_id={op_id} "
        "--ssl_domain_name={ssl_domain_name} "
        "--ssl_root_cert_path={ssl_root_cert_path} "
        "--target_address={target_address} "
        "--use_google_managed_service={use_google_managed_service} "
        "--use_insecure_channel={use_insecure_channel} ")

    if "stream_name" in args:
        manager_app_config[
            "stream_name"] = util.normalize_string_for_commandline(
                args["stream_name"])
        manager_app_tpl += "--stream_name={stream_name} "

    manager_app_cmd = manager_app_tpl.format(**manager_app_config)
    logging.debug("Executing command %s.", manager_app_cmd)
    manager_app_tokens = shlex.split(manager_app_cmd)
    os.execlp(manager_app_tokens[0], *manager_app_tokens)
예제 #4
0
def _exec_manager_app(op_id, args):
    """Execute the manager app for managing streams in managed clusters."""
    manager_app_config = {
        "app_path":
        os.path.join(
            pathlib.Path(apps.__file__).parents[0], _MANAGEMENT_APP_NAME),
        "op_id":
        op_id,
        "target_address":
        util.normalize_string_for_commandline(args["service_address"]),
        "project":
        util.normalize_string_for_commandline(args["project_id"]),
        "cluster_name":
        util.normalize_string_for_commandline(args["cluster_name"]),
        "location":
        util.normalize_string_for_commandline(args["region"]),
        "use_google_managed_service":
        util.to_cpp_bool_string(True),
    }
    manager_app_tpl = (
        "{app_path} "
        "--op_id={op_id} "
        "--target_address={target_address} "
        "--project={project} "
        "--cluster_name={cluster_name} "
        "--location={location} "
        "--use_google_managed_service={use_google_managed_service} ")

    if "stream_name" in args:
        manager_app_config[
            "stream_name"] = util.normalize_string_for_commandline(
                args["stream_name"])
        manager_app_tpl += "--stream_name={stream_name} "

    manager_app_cmd = manager_app_tpl.format(**manager_app_config)
    logging.debug("Executing command %s.", manager_app_cmd)
    manager_app_tokens = shlex.split(manager_app_cmd)
    os.execlp(manager_app_tokens[0], *manager_app_tokens)
예제 #5
0
def cli(target_address, authenticate_with_google, ssl_root_cert_path,
        ssl_domain_name, use_insecure_channel, stream_name, receiver_timeout):
  """Print packets as text onto stdout."""
  printer_app_config = {
      "app_path":
          os.path.join(
              pathlib.Path(apps.__file__).parents[0], _PLAYBACK_APP_NAME),
      "target_address":
          util.normalize_string_for_commandline(target_address),
      "authenticate_with_google":
          util.to_cpp_bool_string(authenticate_with_google),
      "ssl_domain_name":
          util.normalize_string_for_commandline(ssl_domain_name),
      "ssl_root_cert_path":
          util.normalize_string_for_commandline(ssl_root_cert_path),
      "stream_name":
          util.normalize_string_for_commandline(stream_name),
      "use_insecure_channel":
          util.to_cpp_bool_string(use_insecure_channel),
      "timeout_in_sec":
          receiver_timeout,
  }

  printer_app_cmd = ("{app_path} "
                     "--target_address={target_address} "
                     "--authenticate_with_google={authenticate_with_google} "
                     "--ssl_root_cert_path={ssl_root_cert_path} "
                     "--ssl_domain_name={ssl_domain_name} "
                     "--stream_name={stream_name} "
                     "--timeout_in_sec={timeout_in_sec} "
                     "--use_insecure_channel={use_insecure_channel} ".format(
                         **printer_app_config))
  logging.debug("Executing command %s.", printer_app_cmd)

  printer_app_tokens = shlex.split(printer_app_cmd)
  os.execlp(printer_app_tokens[0], *printer_app_tokens)
예제 #6
0
def _exec_chunker_app(args):
    """Execute the chunker app."""
    chunker_app_config = {
        "app_path":
        os.path.join(
            pathlib.Path(apps.__file__).parents[0], _CHUNKER_APP_NAME),
        "max_frames_per_file":
        args["max_frames_per_file"],
        "output_dir":
        util.normalize_string_for_commandline(args["output_dir"]),
        "file_prefix":
        util.normalize_string_for_commandline(args["output_file_prefix"]),
        "upload_to_gcs":
        util.to_cpp_bool_string(args["gcs_bucket_name"]),
        "gcs_bucket_name":
        util.normalize_string_for_commandline(args["gcs_bucket_name"]),
        "gcs_object_dir":
        util.normalize_string_for_commandline(args["gcs_bucket_subdir_name"]),
        "keep_local":
        util.to_cpp_bool_string(args["upload_keep_local"]),
        "use_uri_source":
        util.to_cpp_bool_string("source_uri" in args),
        "working_buffer_size":
        args["working_buffer_size"],
        "finalization_deadline_in_sec":
        args["finalization_deadline_in_sec"],
    }

    chunker_app_tpl = (
        "{app_path} "
        "--max_frames_per_file={max_frames_per_file} "
        "--output_dir={output_dir} "
        "--file_prefix={file_prefix} "
        "--upload_to_gcs={upload_to_gcs} "
        "--gcs_bucket_name={gcs_bucket_name} "
        "--gcs_object_dir={gcs_object_dir} "
        "--keep_local={keep_local} "
        "--use_uri_source={use_uri_source} "
        "--working_buffer_size={working_buffer_size} "
        "--finalization_deadline_in_sec={finalization_deadline_in_sec} ")

    if "source_uri" in args:
        chunker_app_config[
            "source_uri"] = util.normalize_string_for_commandline(
                args["source_uri"])
        chunker_app_tpl += "--source_uri={source_uri} "
    if "gstreamer_input_pipeline" in args:
        chunker_app_config[
            "use_gstreamer_input_source"] = util.to_cpp_bool_string(True)
        chunker_app_config[
            "gstreamer_input_pipeline"] = util.normalize_string_for_commandline(
                args["gstreamer_input_pipeline"])
        chunker_app_tpl += "--use_gstreamer_input_source={use_gstreamer_input_source} "
        chunker_app_tpl += "--gstreamer_input_pipeline={gstreamer_input_pipeline} "
    if "receiver_timeout_in_sec" in args:
        chunker_app_config["receiver_timeout_in_sec"] = args[
            "receiver_timeout_in_sec"]
        chunker_app_tpl += "--receiver_timeout_in_sec={receiver_timeout_in_sec} "
    if "authenticate_with_google" in args:
        chunker_app_config[
            "authenticate_with_google"] = util.to_cpp_bool_string(
                args["authenticate_with_google"])
        chunker_app_tpl += "--authenticate_with_google={authenticate_with_google} "
    if "use_insecure_channel" in args:
        chunker_app_config["use_insecure_channel"] = util.to_cpp_bool_string(
            args["use_insecure_channel"])
        chunker_app_tpl += "--use_insecure_channel={use_insecure_channel} "
    if "target_address" in args:
        chunker_app_config[
            "target_address"] = util.normalize_string_for_commandline(
                args["target_address"])
        chunker_app_tpl += "--target_address={target_address} "
    if "ssl_domain_name" in args:
        chunker_app_config[
            "ssl_domain_name"] = util.normalize_string_for_commandline(
                args["ssl_domain_name"])
        chunker_app_tpl += "--ssl_domain_name={ssl_domain_name} "
    if "ssl_root_cert_path" in args:
        chunker_app_config[
            "ssl_root_cert_path"] = util.normalize_string_for_commandline(
                args["ssl_root_cert_path"])
        chunker_app_tpl += "--ssl_root_cert_path={ssl_root_cert_path} "
    if "stream_name" in args:
        chunker_app_config[
            "stream_name"] = util.normalize_string_for_commandline(
                args["stream_name"])
        chunker_app_tpl += "--stream_name={stream_name} "

    chunker_app_cmd = chunker_app_tpl.format(**chunker_app_config)
    logging.debug("Executing command %s.", chunker_app_cmd)
    chunker_app_tokens = shlex.split(chunker_app_cmd)
    os.execlp(chunker_app_tokens[0], *chunker_app_tokens)