Python botocore.exceptions.ConfigNotFound() Examples
The following are 30
code examples of botocore.exceptions.ConfigNotFound().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
botocore.exceptions
, or try the search function
.
Example #1
Source File: credentials.py From faces with GNU General Public License v2.0 | 6 votes |
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
Example #2
Source File: credentials.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
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
Example #3
Source File: credentials.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
def load(self): """ Look for credentials in boto config file. """ if self.BOTO_CONFIG_ENV in self._environ: potential_locations = [self._environ[self.BOTO_CONFIG_ENV]] else: potential_locations = self.DEFAULT_CONFIG_FILENAMES for filename in potential_locations: try: config = self._ini_parser(filename) except ConfigNotFound: # Move on to the next potential config file name. continue if 'Credentials' in config: credentials = config['Credentials'] if self.ACCESS_KEY in credentials: logger.info("Found credentials in boto config file: %s", filename) access_key, secret_key = self._extract_creds_from_mapping( credentials, self.ACCESS_KEY, self.SECRET_KEY) return Credentials(access_key, secret_key, method=self.METHOD)
Example #4
Source File: credentials.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
def load(self): """ Look for credentials in boto config file. """ if self.BOTO_CONFIG_ENV in self._environ: potential_locations = [self._environ[self.BOTO_CONFIG_ENV]] else: potential_locations = self.DEFAULT_CONFIG_FILENAMES for filename in potential_locations: try: config = self._ini_parser(filename) except ConfigNotFound: # Move on to the next potential config file name. continue if 'Credentials' in config: credentials = config['Credentials'] if self.ACCESS_KEY in credentials: logger.info("Found credentials in boto config file: %s", filename) access_key, secret_key = self._extract_creds_from_mapping( credentials, self.ACCESS_KEY, self.SECRET_KEY) return Credentials(access_key, secret_key, method=self.METHOD)
Example #5
Source File: credentials.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 6 votes |
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
Example #6
Source File: credentials.py From aws-extender with MIT License | 6 votes |
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
Example #7
Source File: credentials.py From bash-lambda-layer with MIT License | 6 votes |
def load(self): """ Look for credentials in boto config file. """ if self.BOTO_CONFIG_ENV in self._environ: potential_locations = [self._environ[self.BOTO_CONFIG_ENV]] else: potential_locations = self.DEFAULT_CONFIG_FILENAMES for filename in potential_locations: try: config = self._ini_parser(filename) except ConfigNotFound: # Move on to the next potential config file name. continue if 'Credentials' in config: credentials = config['Credentials'] if self.ACCESS_KEY in credentials: logger.info("Found credentials in boto config file: %s", filename) access_key, secret_key = self._extract_creds_from_mapping( credentials, self.ACCESS_KEY, self.SECRET_KEY) return Credentials(access_key, secret_key, method=self.METHOD)
Example #8
Source File: credentials.py From bash-lambda-layer with MIT License | 6 votes |
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
Example #9
Source File: credentials.py From aws-extender with MIT License | 6 votes |
def load(self): """ Look for credentials in boto config file. """ if self.BOTO_CONFIG_ENV in self._environ: potential_locations = [self._environ[self.BOTO_CONFIG_ENV]] else: potential_locations = self.DEFAULT_CONFIG_FILENAMES for filename in potential_locations: try: config = self._ini_parser(filename) except ConfigNotFound: # Move on to the next potential config file name. continue if 'Credentials' in config: credentials = config['Credentials'] if self.ACCESS_KEY in credentials: logger.info("Found credentials in boto config file: %s", filename) access_key, secret_key = self._extract_creds_from_mapping( credentials, self.ACCESS_KEY, self.SECRET_KEY) return Credentials(access_key, secret_key, method=self.METHOD)
Example #10
Source File: credentials.py From deepWordBug with Apache License 2.0 | 6 votes |
def load(self): """ Look for credentials in boto config file. """ if self.BOTO_CONFIG_ENV in self._environ: potential_locations = [self._environ[self.BOTO_CONFIG_ENV]] else: potential_locations = self.DEFAULT_CONFIG_FILENAMES for filename in potential_locations: try: config = self._ini_parser(filename) except ConfigNotFound: # Move on to the next potential config file name. continue if 'Credentials' in config: credentials = config['Credentials'] if self.ACCESS_KEY in credentials: logger.info("Found credentials in boto config file: %s", filename) access_key, secret_key = self._extract_creds_from_mapping( credentials, self.ACCESS_KEY, self.SECRET_KEY) return Credentials(access_key, secret_key, method=self.METHOD)
Example #11
Source File: credentials.py From deepWordBug with Apache License 2.0 | 6 votes |
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
Example #12
Source File: session.py From awscli-keyring with MIT License | 6 votes |
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
Example #13
Source File: credentials.py From aws-builders-fair-projects with Apache License 2.0 | 6 votes |
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
Example #14
Source File: credentials.py From faces with GNU General Public License v2.0 | 6 votes |
def load(self): """ Look for credentials in boto config file. """ if self.BOTO_CONFIG_ENV in self._environ: potential_locations = [self._environ[self.BOTO_CONFIG_ENV]] else: potential_locations = self.DEFAULT_CONFIG_FILENAMES for filename in potential_locations: try: config = self._ini_parser(filename) except ConfigNotFound: # Move on to the next potential config file name. continue if 'Credentials' in config: credentials = config['Credentials'] if self.ACCESS_KEY in credentials: logger.info("Found credentials in boto config file: %s", filename) access_key, secret_key = self._extract_creds_from_mapping( credentials, self.ACCESS_KEY, self.SECRET_KEY) return Credentials(access_key, secret_key, method=self.METHOD)
Example #15
Source File: credentials.py From faces with GNU General Public License v2.0 | 6 votes |
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
Example #16
Source File: credentials.py From aws-builders-fair-projects with Apache License 2.0 | 6 votes |
def load(self): """ Look for credentials in boto config file. """ if self.BOTO_CONFIG_ENV in self._environ: potential_locations = [self._environ[self.BOTO_CONFIG_ENV]] else: potential_locations = self.DEFAULT_CONFIG_FILENAMES for filename in potential_locations: try: config = self._ini_parser(filename) except ConfigNotFound: # Move on to the next potential config file name. continue if 'Credentials' in config: credentials = config['Credentials'] if self.ACCESS_KEY in credentials: logger.info("Found credentials in boto config file: %s", filename) access_key, secret_key = self._extract_creds_from_mapping( credentials, self.ACCESS_KEY, self.SECRET_KEY) return Credentials(access_key, secret_key, method=self.METHOD)
Example #17
Source File: credentials.py From faces with GNU General Public License v2.0 | 6 votes |
def load(self): """ Look for credentials in boto config file. """ if self.BOTO_CONFIG_ENV in self._environ: potential_locations = [self._environ[self.BOTO_CONFIG_ENV]] else: potential_locations = self.DEFAULT_CONFIG_FILENAMES for filename in potential_locations: try: config = self._ini_parser(filename) except ConfigNotFound: # Move on to the next potential config file name. continue if 'Credentials' in config: credentials = config['Credentials'] if self.ACCESS_KEY in credentials: logger.info("Found credentials in boto config file: %s", filename) access_key, secret_key = self._extract_creds_from_mapping( credentials, self.ACCESS_KEY, self.SECRET_KEY) return Credentials(access_key, secret_key, method=self.METHOD)
Example #18
Source File: credentials.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
def load(self): try: available_creds = self._ini_parser(self._creds_filename) except ConfigNotFound: return None if self._profile_name in available_creds: config = available_creds[self._profile_name] if self.ACCESS_KEY in config: logger.info("Found credentials in shared credentials file: %s", self._creds_filename) access_key, secret_key = self._extract_creds_from_mapping( config, self.ACCESS_KEY, self.SECRET_KEY) token = self._get_session_token(config) return Credentials(access_key, secret_key, token, method=self.METHOD)
Example #19
Source File: session.py From aws-extender with MIT License | 5 votes |
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]
Example #20
Source File: utils.py From aws-extender with MIT License | 5 votes |
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)
Example #21
Source File: credentials.py From aws-extender with MIT License | 5 votes |
def load(self): try: available_creds = self._ini_parser(self._creds_filename) except ConfigNotFound: return None if self._profile_name in available_creds: config = available_creds[self._profile_name] if self.ACCESS_KEY in config: logger.info("Found credentials in shared credentials file: %s", self._creds_filename) access_key, secret_key = self._extract_creds_from_mapping( config, self.ACCESS_KEY, self.SECRET_KEY) token = self._get_session_token(config) return Credentials(access_key, secret_key, token, method=self.METHOD)
Example #22
Source File: session.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
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
Example #23
Source File: session.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
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]
Example #24
Source File: credentials.py From faces with GNU General Public License v2.0 | 5 votes |
def load(self): try: available_creds = self._ini_parser(self._creds_filename) except ConfigNotFound: return None if self._profile_name in available_creds: config = available_creds[self._profile_name] if self.ACCESS_KEY in config: logger.info("Found credentials in shared credentials file: %s", self._creds_filename) access_key, secret_key = self._extract_creds_from_mapping( config, self.ACCESS_KEY, self.SECRET_KEY) token = self._get_session_token(config) return Credentials(access_key, secret_key, token, method=self.METHOD)
Example #25
Source File: session.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
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]
Example #26
Source File: session.py From aws-builders-fair-projects with Apache License 2.0 | 5 votes |
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
Example #27
Source File: session.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
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
Example #28
Source File: session.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
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]
Example #29
Source File: credentials.py From AWS-Transit-Gateway-Demo-MultiAccount with MIT License | 5 votes |
def load(self): try: available_creds = self._ini_parser(self._creds_filename) except ConfigNotFound: return None if self._profile_name in available_creds: config = available_creds[self._profile_name] if self.ACCESS_KEY in config: logger.info("Found credentials in shared credentials file: %s", self._creds_filename) access_key, secret_key = self._extract_creds_from_mapping( config, self.ACCESS_KEY, self.SECRET_KEY) token = self._get_session_token(config) return Credentials(access_key, secret_key, token, method=self.METHOD)
Example #30
Source File: session.py From bash-lambda-layer with MIT License | 5 votes |
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