Merge branch 'powerline:develop' into issue2221
This commit is contained in:
commit
810f7515f9
|
@ -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
|
||||||
|
@ -17,9 +19,19 @@ class EmailIMAPSegment(KwThreadedSegment):
|
||||||
interval = 60
|
interval = 60
|
||||||
|
|
||||||
@staticmethod
|
@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', port=IMAP4_SSL_PORT, username_variable='', password_variable='', server_variable='', port_variable='', folder='INBOX', use_ssl=None, **kwargs):
|
||||||
if use_ssl is None:
|
if use_ssl is None:
|
||||||
use_ssl = (port == IMAP4_SSL_PORT)
|
use_ssl = (port == IMAP4_SSL_PORT)
|
||||||
|
# catch if user set custom mail credential env variables
|
||||||
|
if username_variable:
|
||||||
|
username = os.environ[username_variable]
|
||||||
|
if password_variable:
|
||||||
|
password = os.environ[password_variable]
|
||||||
|
if server_variable:
|
||||||
|
server = os.environ[server_variable]
|
||||||
|
if port_variable:
|
||||||
|
port = os.environ[port_variable]
|
||||||
|
|
||||||
return _IMAPKey(username, password, server, port, folder, use_ssl)
|
return _IMAPKey(username, password, server, port, folder, use_ssl)
|
||||||
|
|
||||||
def compute_state(self, key):
|
def compute_state(self, key):
|
||||||
|
@ -64,6 +76,14 @@ email_imap_alert = with_docstring(EmailIMAPSegment(),
|
||||||
e-mail server
|
e-mail server
|
||||||
:param int port:
|
:param int port:
|
||||||
e-mail server port
|
e-mail server port
|
||||||
|
:param str username_variable:
|
||||||
|
name of environment variable to check for login username
|
||||||
|
:param str password_variable:
|
||||||
|
name of environment variable to check for login password
|
||||||
|
:param str server_variable:
|
||||||
|
name of environment variable to check for email server
|
||||||
|
:param str port_variable:
|
||||||
|
name of environment variable to check for email server port
|
||||||
:param str folder:
|
:param str folder:
|
||||||
folder to check for e-mails
|
folder to check for e-mails
|
||||||
:param int max_msgs:
|
:param int max_msgs:
|
||||||
|
|
Loading…
Reference in New Issue