make username/password optional for mail, and fix getting env var typo

This commit is contained in:
Jesse Hitch 2022-12-18 00:46:36 +01:00
parent 85d5092028
commit e906045841
No known key found for this signature in database
GPG Key ID: C01D207CE04D55D9
1 changed files with 4 additions and 4 deletions

View File

@ -19,16 +19,16 @@ class EmailIMAPSegment(KwThreadedSegment):
interval = 60
@staticmethod
def key(username, password, server='imap.gmail.com', port=IMAP4_SSL_PORT, folder='INBOX', use_ssl=None, **kwargs):
def key(username='', password='', server='imap.gmail.com', username_variable='', password_variable='', server_variable='', port=IMAP4_SSL_PORT, folder='INBOX', use_ssl=None, **kwargs):
if use_ssl is None:
use_ssl = (port == IMAP4_SSL_PORT)
# catch if user set custom mail credential env variables
if username_variable:
username = os.environ.get(username_variable, None)
username = os.environ[username_variable]
if password_variable:
password = os.environ.get(password_variable, None)
password = os.environ[password_variable]
if server_variable:
server = os.enviorn.get(server_variable, server)
server = os.environ[server_variable]
return _IMAPKey(username, password, server, port, folder, use_ssl)