|
6 | 6 | __author__ = 'Simon Robinson' |
7 | 7 | __copyright__ = 'Copyright (c) 2024 Simon Robinson' |
8 | 8 | __license__ = 'Apache 2.0' |
9 | | -__version__ = '2024-01-17' # ISO 8601 (YYYY-MM-DD) |
| 9 | +__version__ = '2024-01-20' # ISO 8601 (YYYY-MM-DD) |
10 | 10 | __package_version__ = '.'.join([str(int(i)) for i in __version__.split('-')]) # for pyproject.toml usage only |
11 | 11 |
|
12 | 12 | import abc |
@@ -340,6 +340,7 @@ def save(store_id, config_dict): |
340 | 340 |
|
341 | 341 |
|
342 | 342 | class AWSSecretsManagerCacheStore(CacheStore): |
| 343 | + # noinspection PyUnresolvedReferences |
343 | 344 | @staticmethod |
344 | 345 | def _get_boto3_client(store_id): |
345 | 346 | try: |
@@ -568,7 +569,7 @@ def save(): |
568 | 569 | return |
569 | 570 |
|
570 | 571 | if CACHE_STORE != CONFIG_FILE_PATH: |
571 | | - # in `--cache-store` mode we ignore everything except _CACHED_OPTION_KEYS (OAuth 2.0 tokens, etc) |
| 572 | + # in `--cache-store` mode we ignore everything except _CACHED_OPTION_KEYS (OAuth 2.0 tokens, etc.) |
572 | 573 | output_config_parser = configparser.ConfigParser(interpolation=None) |
573 | 574 | output_config_parser.read_dict(AppConfig._PARSER) # a deep copy of the current configuration |
574 | 575 | config_accounts = [s for s in output_config_parser.sections() if '@' in s] |
@@ -678,6 +679,7 @@ class TokenRefreshError(Exception): |
678 | 679 |
|
679 | 680 | @staticmethod |
680 | 681 | def get_oauth2_credentials(username, password, reload_remote_accounts=True): |
| 682 | + # noinspection GrazieInspection |
681 | 683 | """Using the given username (i.e., email address) and password, reads account details from AppConfig and |
682 | 684 | handles OAuth 2.0 token request and renewal, saving the updated details back to AppConfig (or removing them |
683 | 685 | if invalid). Returns either (True, '[OAuth2 string for authentication]') or (False, '[Error message]')""" |
@@ -1067,6 +1069,7 @@ def get_oauth2_authorisation_tokens(token_url, redirect_uri, client_id, client_s |
1067 | 1069 | Log.debug('Error requesting access token - received invalid response:', e.message) |
1068 | 1070 | raise e |
1069 | 1071 |
|
| 1072 | + # noinspection PyUnresolvedReferences |
1070 | 1073 | @staticmethod |
1071 | 1074 | def get_service_account_authorisation_token(key_type, key_path_or_contents, oauth2_scope, username): |
1072 | 1075 | """Requests an authorisation token via a Service Account key (currently Google Cloud only)""" |
@@ -1144,7 +1147,7 @@ def encode_oauth2_string(input_string): |
1144 | 1147 |
|
1145 | 1148 | @staticmethod |
1146 | 1149 | def strip_quotes(text): |
1147 | | - """Remove double quotes (i.e., " characters) around a string - used for IMAP LOGIN command""" |
| 1150 | + """Remove double quotes (i.e., "" characters) around a string - used for IMAP LOGIN command""" |
1148 | 1151 | if text.startswith('"') and text.endswith('"'): |
1149 | 1152 | return text[1:-1].replace(r'\"', '"') # also need to fix any escaped quotes within the string |
1150 | 1153 | return text |
@@ -1794,10 +1797,11 @@ def handle_error(self): |
1794 | 1797 | error_type, value = Log.get_last_error() |
1795 | 1798 | if error_type == TimeoutError and value.errno == errno.ETIMEDOUT or \ |
1796 | 1799 | issubclass(error_type, ConnectionError) and value.errno in [errno.ECONNRESET, errno.ECONNREFUSED] or \ |
1797 | | - error_type == OSError and value.errno in [0, errno.ENETDOWN, errno.EHOSTDOWN, errno.EHOSTUNREACH]: |
| 1800 | + error_type == OSError and value.errno in [0, errno.ENETDOWN, errno.ENETUNREACH, errno.EHOSTDOWN, |
| 1801 | + errno.EHOSTUNREACH]: |
1798 | 1802 | # TimeoutError 60 = 'Operation timed out'; ConnectionError 54 = 'Connection reset by peer', 61 = 'Connection |
1799 | | - # refused; OSError 0 = 'Error' (typically network failure), 50 = 'Network is down', 64 = 'Host is down'; |
1800 | | - # 65 = 'No route to host' |
| 1803 | + # refused; OSError 0 = 'Error' (typically network failure), 50 = 'Network is down', 51 = 'Network is |
| 1804 | + # unreachable'; 64 = 'Host is down'; 65 = 'No route to host' |
1801 | 1805 | Log.info(self.info_string(), 'Caught network error (server) - is there a network connection?', |
1802 | 1806 | 'Error type', error_type, 'with message:', value) |
1803 | 1807 | self.close() |
|
0 commit comments