mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-30 01:37:17 +00:00
Test notification
Minor pep8 fixes
This commit is contained in:
parent
a414a84044
commit
93a3c5779c
1 changed files with 10 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*-coding:UTF-8 -*
|
||||
|
||||
import argparse
|
||||
import configparser
|
||||
import os
|
||||
import smtplib
|
||||
|
@ -21,6 +22,7 @@ TrackedTermsNotificationEnabled_Name = "TrackedNotifications"
|
|||
# Keys will be e.g. TrackedNotificationEmails<TERMNAME>
|
||||
TrackedTermsNotificationEmailsPrefix_Name = "TrackedNotificationEmails_"
|
||||
|
||||
|
||||
def sendEmailNotification(recipient, alert_name, content):
|
||||
|
||||
if not os.path.exists(configfile):
|
||||
|
@ -69,7 +71,6 @@ def sendEmailNotification(recipient, alert_name, content):
|
|||
else:
|
||||
smtp_server = smtplib.SMTP(sender_host, sender_port)
|
||||
|
||||
|
||||
mime_msg = MIMEMultipart()
|
||||
mime_msg['From'] = sender
|
||||
mime_msg['To'] = recipient
|
||||
|
@ -85,3 +86,9 @@ def sendEmailNotification(recipient, alert_name, content):
|
|||
except Exception as e:
|
||||
print(str(e))
|
||||
# raise e
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Test notification sender.')
|
||||
parser.add_argument("addr", help="Test mail 'to' address")
|
||||
args = parser.parse_args()
|
||||
sendEmailNotification(args.addr, '_mail test_', 'Success.')
|
||||
|
|
Loading…
Reference in a new issue