diff --git a/reportportal_client/services/client_id.py b/reportportal_client/services/client_id.py index 1f8f8731..c0805143 100644 --- a/reportportal_client/services/client_id.py +++ b/reportportal_client/services/client_id.py @@ -69,16 +69,12 @@ def _read_client_id(): def _store_client_id(client_id): config = __read_config() - try: - if not os.path.exists(RP_FOLDER_PATH): - os.makedirs(RP_FOLDER_PATH) - config.set(__NoSectionConfigParser.DEFAULT_SECTION, CLIENT_ID_PROPERTY, - client_id) - with open(RP_PROPERTIES_FILE_PATH, 'w') as fp: - config.write(fp) - except (PermissionError, IOError) as error: - logger.exception('[%s] Unknown exception has occurred. ' - 'Skipping client ID saving.', error) + if not os.path.exists(RP_FOLDER_PATH): + os.makedirs(RP_FOLDER_PATH) + config.set(__NoSectionConfigParser.DEFAULT_SECTION, CLIENT_ID_PROPERTY, + client_id) + with open(RP_PROPERTIES_FILE_PATH, 'w') as fp: + config.write(fp) def get_client_id(): @@ -86,5 +82,9 @@ def get_client_id(): client_id = _read_client_id() if not client_id: client_id = str(uuid4()) - _store_client_id(client_id) + try: + _store_client_id(client_id) + except (PermissionError, IOError) as error: + logger.exception('[%s] Unknown exception has occurred. ' + 'Skipping client ID saving.', error) return client_id