Skip to content

Commit

Permalink
Chore/usync logs (#775)
Browse files Browse the repository at this point in the history
* chore(logs): Improve warning about filename pattern/encryption

* chore(logs): Improve error msg where bad decrypt key is probable issue
  • Loading branch information
vpsx committed May 7, 2020
1 parent 78fb020 commit 12583a2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fence/sync/sync_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
)
Expand Down

0 comments on commit 12583a2

Please sign in to comment.