mirror of
https://github.com/powerline/powerline.git
synced 2025-07-31 01:35:40 +02:00
Check env vars for mail username and password
This commit is contained in:
parent
8b07f63961
commit
fecba2d34a
@ -1,6 +1,8 @@
|
|||||||
# vim:fileencoding=utf-8:noet
|
# vim:fileencoding=utf-8:noet
|
||||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from imaplib import IMAP4_SSL_PORT, IMAP4_SSL, IMAP4
|
from imaplib import IMAP4_SSL_PORT, IMAP4_SSL, IMAP4
|
||||||
@ -24,6 +26,13 @@ class EmailIMAPSegment(KwThreadedSegment):
|
|||||||
|
|
||||||
def compute_state(self, key):
|
def compute_state(self, key):
|
||||||
if not key.username or not key.password:
|
if not key.username or not key.password:
|
||||||
|
# check environmental variables for username and password
|
||||||
|
mail_user = os.environ.get('MAIL_USER', None)
|
||||||
|
mail_pass = os.environ.get('MAIL_PASSWORD', None)
|
||||||
|
if mail_user and mail_password:
|
||||||
|
key.username = mail_user
|
||||||
|
key.password = mail_password
|
||||||
|
else:
|
||||||
self.warn('Username and password are not configured')
|
self.warn('Username and password are not configured')
|
||||||
return None
|
return None
|
||||||
if key.use_ssl:
|
if key.use_ssl:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user