Merge pull request #50 from knatsakis/knats-fix-remoteusereval
BUG: Right format for username using remoteusereval
This commit is contained in:
commit
18c6612587
@ -206,12 +206,23 @@ class IMAPRepository(BaseRepository):
|
|||||||
Returns: Returns the remoteusereval or remoteuser or netrc user value.
|
Returns: Returns the remoteusereval or remoteuser or netrc user value.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
localeval = self.localeval
|
|
||||||
|
|
||||||
if self.config.has_option(self.getsection(), 'remoteusereval'):
|
if self.config.has_option(self.getsection(), 'remoteusereval'):
|
||||||
user = self.getconf('remoteusereval')
|
user = self.getconf('remoteusereval')
|
||||||
if user is not None:
|
if user is not None:
|
||||||
return localeval.eval(user).encode('UTF-8')
|
l_user = self.localeval.eval(user)
|
||||||
|
|
||||||
|
# We need a str username
|
||||||
|
if isinstance(l_user, bytes):
|
||||||
|
return l_user.decode(encoding='utf-8')
|
||||||
|
elif isinstance(l_user, str):
|
||||||
|
return l_user
|
||||||
|
|
||||||
|
# If is not bytes or str, we have a problem
|
||||||
|
raise OfflineImapError("Could not get a right username format for"
|
||||||
|
" repository %s. Type found: %s. "
|
||||||
|
"Please, open a bug." %
|
||||||
|
(self.name, type(l_user)),
|
||||||
|
OfflineImapError.ERROR.FOLDER)
|
||||||
|
|
||||||
if self.config.has_option(self.getsection(), 'remoteuser'):
|
if self.config.has_option(self.getsection(), 'remoteuser'):
|
||||||
# Assume the configuration file to be UTF-8 encoded so we must not
|
# Assume the configuration file to be UTF-8 encoded so we must not
|
||||||
|
Loading…
Reference in New Issue
Block a user