当前位置: 首页>>代码示例>>Python>>正文


Python botocore.utils方法代码示例

本文整理汇总了Python中botocore.utils方法的典型用法代码示例。如果您正苦于以下问题:Python botocore.utils方法的具体用法?Python botocore.utils怎么用?Python botocore.utils使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在botocore的用法示例。


在下文中一共展示了botocore.utils方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_tmp_folder

# 需要导入模块: import botocore [as 别名]
# 或者: from botocore import utils [as 别名]
def _create_tmp_folder(self):
        """Placeholder docstring"""
        root_dir = sagemaker.utils.get_config_value(
            "local.container_root", self.sagemaker_session.config
        )
        if root_dir:
            root_dir = os.path.abspath(root_dir)

        working_dir = tempfile.mkdtemp(dir=root_dir)

        # Docker cannot mount Mac OS /var folder properly see
        # https://forums.docker.com/t/var-folders-isnt-mounted-properly/9600
        # Only apply this workaround if the user didn't provide an alternate storage root dir.
        if root_dir is None and platform.system() == "Darwin":
            working_dir = "/private{}".format(working_dir)

        return os.path.abspath(working_dir) 
开发者ID:aws,项目名称:sagemaker-python-sdk,代码行数:19,代码来源:image.py

示例2: add_glacier_checksums

# 需要导入模块: import botocore [as 别名]
# 或者: from botocore import utils [as 别名]
def add_glacier_checksums(params, **kwargs):
    """Add glacier checksums to the http request.

    This will add two headers to the http request:

        * x-amz-content-sha256
        * x-amz-sha256-tree-hash

    These values will only be added if they are not present
    in the HTTP request.

    """
    request_dict = params
    headers = request_dict['headers']
    body = request_dict['body']
    if isinstance(body, six.binary_type):
        # If the user provided a bytes type instead of a file
        # like object, we're temporarily create a BytesIO object
        # so we can use the util functions to calculate the
        # checksums which assume file like objects.  Note that
        # we're not actually changing the body in the request_dict.
        body = six.BytesIO(body)
    starting_position = body.tell()
    if 'x-amz-content-sha256' not in headers:
        headers['x-amz-content-sha256'] = utils.calculate_sha256(
            body, as_hex=True)
    body.seek(starting_position)
    if 'x-amz-sha256-tree-hash' not in headers:
        headers['x-amz-sha256-tree-hash'] = utils.calculate_tree_hash(body)
    body.seek(starting_position) 
开发者ID:skarlekar,项目名称:faces,代码行数:32,代码来源:handlers.py

示例3: _create_docker_host

# 需要导入模块: import botocore [as 别名]
# 或者: from botocore import utils [as 别名]
def _create_docker_host(self, host, environment, optml_subdirs, command, volumes):
        """
        Args:
            host:
            environment:
            optml_subdirs:
            command:
            volumes:
        """
        optml_volumes = self._build_optml_volumes(host, optml_subdirs)
        optml_volumes.extend(volumes)

        host_config = {
            "image": self.image,
            "stdin_open": True,
            "tty": True,
            "volumes": [v.map for v in optml_volumes],
            "environment": environment,
            "command": command,
            "networks": {"sagemaker-local": {"aliases": [host]}},
        }

        # for GPU support pass in nvidia as the runtime, this is equivalent
        # to setting --runtime=nvidia in the docker commandline.
        if self.instance_type == "local_gpu":
            host_config["runtime"] = "nvidia"

        if command == "serve":
            serving_port = (
                sagemaker.utils.get_config_value(
                    "local.serving_port", self.sagemaker_session.config
                )
                or 8080
            )
            host_config.update({"ports": ["%s:8080" % serving_port]})

        return host_config 
开发者ID:aws,项目名称:sagemaker-python-sdk,代码行数:39,代码来源:image.py

示例4: _aws_credentials_available_in_metadata_service

# 需要导入模块: import botocore [as 别名]
# 或者: from botocore import utils [as 别名]
def _aws_credentials_available_in_metadata_service():
    """Placeholder docstring"""
    import botocore
    from botocore.credentials import InstanceMetadataProvider
    from botocore.utils import InstanceMetadataFetcher

    session = botocore.session.Session()
    instance_metadata_provider = InstanceMetadataProvider(
        iam_role_fetcher=InstanceMetadataFetcher(
            timeout=session.get_config_variable("metadata_service_timeout"),
            num_attempts=session.get_config_variable("metadata_service_num_attempts"),
            user_agent=session.user_agent(),
        )
    )
    return not instance_metadata_provider.load() is None 
开发者ID:aws,项目名称:sagemaker-python-sdk,代码行数:17,代码来源:image.py

示例5: _ecr_login_if_needed

# 需要导入模块: import botocore [as 别名]
# 或者: from botocore import utils [as 别名]
def _ecr_login_if_needed(boto_session, image):
    # Only ECR images need login
    """
    Args:
        boto_session:
        image:
    """
    sagemaker_pattern = re.compile(sagemaker.utils.ECR_URI_PATTERN)
    sagemaker_match = sagemaker_pattern.match(image)
    if not sagemaker_match:
        return False

    # do we have the image?
    if _check_output("docker images -q %s" % image).strip():
        return False

    if not boto_session:
        raise RuntimeError(
            "A boto session is required to login to ECR."
            "Please pull the image: %s manually." % image
        )

    ecr = boto_session.client("ecr")
    auth = ecr.get_authorization_token(registryIds=[image.split(".")[0]])
    authorization_data = auth["authorizationData"][0]

    raw_token = base64.b64decode(authorization_data["authorizationToken"])
    token = raw_token.decode("utf-8").strip("AWS:")
    ecr_url = auth["authorizationData"][0]["proxyEndpoint"]

    cmd = "docker login -u AWS -p %s %s" % (token, ecr_url)
    subprocess.check_output(cmd, shell=True)

    return True 
开发者ID:aws,项目名称:sagemaker-python-sdk,代码行数:36,代码来源:image.py

示例6: document_glacier_tree_hash_checksum

# 需要导入模块: import botocore [as 别名]
# 或者: from botocore import utils [as 别名]
def document_glacier_tree_hash_checksum():
    doc = '''
        This is a required field.

        Ideally you will want to compute this value with checksums from
        previous uploaded parts, using the algorithm described in
        `Glacier documentation <http://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html>`_.

        But if you prefer, you can also use botocore.utils.calculate_tree_hash()
        to compute it from raw file by::

            checksum = calculate_tree_hash(open('your_file.txt', 'rb'))

        '''
    return AppendParamDocumentation('checksum', doc).append_documentation 
开发者ID:QData,项目名称:deepWordBug,代码行数:17,代码来源:handlers.py


注:本文中的botocore.utils方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。