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


Python exceptions.ConfigNotFound方法代码示例

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


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

示例1: load

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import ConfigNotFound [as 别名]
def load(self):
        """
        If there is are credentials in the configuration associated with
        the session, use those.
        """
        try:
            full_config = self._config_parser(self._config_filename)
        except ConfigNotFound:
            return None
        if self._profile_name in full_config['profiles']:
            profile_config = full_config['profiles'][self._profile_name]
            if self.ACCESS_KEY in profile_config:
                logger.info("Credentials found in config file: %s",
                            self._config_filename)
                access_key, secret_key = self._extract_creds_from_mapping(
                    profile_config, self.ACCESS_KEY, self.SECRET_KEY)
                token = self._get_session_token(profile_config)
                return Credentials(access_key, secret_key, token,
                                   method=self.METHOD)
        else:
            return None 
开发者ID:skarlekar,项目名称:faces,代码行数:23,代码来源:credentials.py

示例2: initialized

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import ConfigNotFound [as 别名]
def initialized(session, **kwargs):
    session.session_var_map["keyring"] = ("keyring", None, False, cast_bool)

    try:
        if session.get_config_variable("keyring") != False:
            if session.profile is not None:
                profile = session.profile
            else:
                profile = "default"

            key, secret = persistence.get_credentials(profile)

            session.set_credentials(key, secret)

    except (ConfigNotFound, ProfileNotFound):
        pass 
开发者ID:sj26,项目名称:awscli-keyring,代码行数:18,代码来源:session.py

示例3: parse_key_val_file

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import ConfigNotFound [as 别名]
def parse_key_val_file(filename, _open=open):
    try:
        with _open(filename) as f:
            contents = f.read()
            return parse_key_val_file_contents(contents)
    except OSError:
        raise ConfigNotFound(path=filename) 
开发者ID:skarlekar,项目名称:faces,代码行数:9,代码来源:utils.py

示例4: get_scoped_config

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import ConfigNotFound [as 别名]
def get_scoped_config(self):
        """
        Returns the config values from the config file scoped to the current
        profile.

        The configuration data is loaded **only** from the config file.
        It does not resolve variables based on different locations
        (e.g. first from the session instance, then from environment
        variables, then from the config file).  If you want this lookup
        behavior, use the ``get_config_variable`` method instead.

        Note that this configuration is specific to a single profile (the
        ``profile`` session variable).

        If the ``profile`` session variable is set and the profile does
        not exist in the config file, a ``ProfileNotFound`` exception
        will be raised.

        :raises: ConfigNotFound, ConfigParseError, ProfileNotFound
        :rtype: dict

        """
        profile_name = self.get_config_variable('profile')
        profile_map = self._build_profile_map()
        # If a profile is not explicitly set return the default
        # profile config or an empty config dict if we don't have
        # a default profile.
        if profile_name is None:
            return profile_map.get('default', {})
        elif profile_name not in profile_map:
            # Otherwise if they specified a profile, it has to
            # exist (even if it's the default profile) otherwise
            # we complain.
            raise ProfileNotFound(profile=profile_name)
        else:
            return profile_map[profile_name] 
开发者ID:skarlekar,项目名称:faces,代码行数:38,代码来源:session.py

示例5: full_config

# 需要导入模块: from botocore import exceptions [as 别名]
# 或者: from botocore.exceptions import ConfigNotFound [as 别名]
def full_config(self):
        """Return the parsed config file.

        The ``get_config`` method returns the config associated with the
        specified profile.  This property returns the contents of the
        **entire** config file.

        :rtype: dict
        """
        if self._config is None:
            try:
                config_file = self.get_config_variable('config_file')
                self._config = botocore.configloader.load_config(config_file)
            except ConfigNotFound:
                self._config = {'profiles': {}}
            try:
                # Now we need to inject the profiles from the
                # credentials file.  We don't actually need the values
                # in the creds file, only the profile names so that we
                # can validate the user is not referring to a nonexistent
                # profile.
                cred_file = self.get_config_variable('credentials_file')
                cred_profiles = botocore.configloader.raw_config_parse(
                    cred_file)
                for profile in cred_profiles:
                    cred_vars = cred_profiles[profile]
                    if profile not in self._config['profiles']:
                        self._config['profiles'][profile] = cred_vars
                    else:
                        self._config['profiles'][profile].update(cred_vars)
            except ConfigNotFound:
                pass
        return self._config 
开发者ID:QData,项目名称:deepWordBug,代码行数:35,代码来源:session.py


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