From 12583a27b6ba1a3a540794048cd2c5df2bf33684 Mon Sep 17 00:00:00 2001 From: vpsx <19900057+vpsx@users.noreply.github.com> Date: Thu, 7 May 2020 16:58:03 -0500 Subject: [PATCH] Chore/usync logs (#775) * chore(logs): Improve warning about filename pattern/encryption * chore(logs): Improve error msg where bad decrypt key is probable issue --- fence/sync/sync_users.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fence/sync/sync_users.py b/fence/sync/sync_users.py index 0dabace19..d9f1192ce 100644 --- a/fence/sync/sync_users.py +++ b/fence/sync/sync_users.py @@ -113,7 +113,10 @@ def _read_file(filepath, encrypted=True, key=None, logger=None): stderr=open(os.devnull, "w"), universal_newlines=True, ) - yield StringIO(p.communicate()[0]) + try: + yield StringIO(p.communicate()[0]) + except UnicodeDecodeError: + logger.error("Could not decode file. Check the decryption key.") else: f = open(filepath, "r") yield f @@ -456,7 +459,10 @@ def _parse_csv(self, file_dict, sess, dbgap_config={}, encrypted=True): continue if not self._match_pattern(filepath, encrypted=encrypted): self.logger.warning( - "Invalid filename {} does not match dbgap access control filename pattern".format( + "Filename {} does not match dbgap access control filename pattern;" + " this could mean that the filename has an invalid format, or has" + " an unexpected .enc extension, or lacks the .enc extension where" + " expected. This file is NOT being processed by usersync!".format( filepath ) )