Stay organized with collections
Save and categorize content based on your preferences.
Source code for google.appengine.api.client_deployinfo
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Client deploy info.
Library for parsing client_deploy.yaml files and working with these in memory.
"""
from __future__ import absolute_import
import os
if os.environ.get('APPENGINE_RUNTIME') == 'python27':
from google.appengine.api import appinfo
from google.appengine.api import validation
from google.appengine.api import yaml_builder
from google.appengine.api import yaml_listener
from google.appengine.api import yaml_object
else:
from google.appengine.api import appinfo
from google.appengine.api import validation
from google.appengine.api import yaml_builder
from google.appengine.api import yaml_listener
from google.appengine.api import yaml_object
RUNTIME = 'runtime'
START_TIME_USEC = 'start_time_usec'
END_TIME_USEC = 'end_time_usec'
REQUESTS = 'requests'
SUCCESS = 'success'
PATH = 'path'
RESPONSE_CODE = 'response_code'
REQUEST_SIZE_BYTES = 'request_size_bytes'
SDK_VERSION = 'sdk_version'
[docs]class Request(validation.Validated):
"""A Request describes a single http request within a deployment attempt."""
ATTRIBUTES = {
PATH: validation.TYPE_STR,
RESPONSE_CODE: validation.Range(100, 599),
START_TIME_USEC: validation.TYPE_LONG,
END_TIME_USEC: validation.TYPE_LONG,
REQUEST_SIZE_BYTES: validation.TYPE_LONG,
}
[docs]class ClientDeployInfoExternal(validation.Validated):
"""Describes the format of a client_deployinfo.yaml file."""
ATTRIBUTES = {
RUNTIME: appinfo.RUNTIME_RE_STRING,
START_TIME_USEC: validation.TYPE_LONG,
END_TIME_USEC: validation.TYPE_LONG,
REQUESTS: validation.Optional(validation.Repeated(Request)),
SUCCESS: validation.TYPE_BOOL,
SDK_VERSION: validation.Optional(validation.TYPE_STR)
}
[docs]class Error(Exception):
"""Base ClientDeployInfo Exception type."""
[docs]class EmptyYaml(Error):
"""Tried to load an empty yaml."""
[docs]class MultipleClientDeployInfo(Error):
"""Tried to load a yaml containing multiple client deploy info definitions."""
[docs]def LoadSingleClientDeployInfo(client_deploy_info):
"""Returns a ClientDeployInfoExternal from a deploy_info.yaml file or string.
Args:
client_deploy_info: The contents of a client_deploy_info.yaml file or
string, or an open file object.
Returns:
A ClientDeployInfoExternal instance which represents the contents of the
parsed yaml.
Raises:
EmptyYaml: when there are no documents in yaml.
MultipleClientDeployInfo: when there are multiple documents in yaml.
yaml_errors.EventError: when an error occurs while parsing the yaml.
"""
builder = yaml_object.ObjectBuilder(ClientDeployInfoExternal)
handler = yaml_builder.BuilderHandler(builder)
listener = yaml_listener.EventListener(handler)
listener.Parse(client_deploy_info)
parsed_yaml = handler.GetResults()
if not parsed_yaml:
raise EmptyYaml()
if len(parsed_yaml) > 1:
raise MultipleClientDeployInfo()
return parsed_yaml[0]
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-16 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-16 UTC."],[[["This code provides a library for parsing `client_deploy.yaml` files and managing the data in memory, specifically for Google App Engine deployments."],["The `Request` class details a single HTTP request within a deployment, including attributes like path, response code, start and end times, and request size."],["The `ClientDeployInfoExternal` class defines the structure of the `client_deployinfo.yaml` file, including runtime, start and end times, requests, success status, and SDK version."],["Several error classes, such as `EmptyYaml` and `MultipleClientDeployInfo`, are defined for handling specific issues during the parsing of the yaml file."],["The `LoadSingleClientDeployInfo` function processes a `client_deploy_info.yaml` file or string, and returns a `ClientDeployInfoExternal` instance representing the parsed YAML data."]]],[]]