Skip to content

Commit

Permalink
Merge pull request #69 from pavithrarp/caliper_integ
Browse files Browse the repository at this point in the history
Email option to send the summary to users are merged.
  • Loading branch information
shyjupv authored Jan 19, 2017
2 parents a20336e + a963b74 commit 04ab55c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
43 changes: 40 additions & 3 deletions caliper
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,48 @@ if __name__=="__main__":
flag = generate_web_tar()

if args.webpage and args.send_email:
flag = generate_web_tar()
result_path = os.path.join(caliper_path.folder_ope.results_dir,
flag = generate_web_tar()
result_path = os.path.join(caliper_path.folder_ope.results_dir,
'test_results.tar.gz')
if os.path.exists(result_path):
if os.path.exists(result_path):
send_mails.send_mails(result_path)
print("\n'test_results.tar.gz file has been sent, please check the mail\n")
sys.exit()
if not os.path.exists(result_path):
try:
os.makedirs(caliper_path.folder_ope.workspace)
except Exception as e:
print("\nCan't able to send the mail as 'test_results.tar.gz' file is not created\n")
sys.exit()


if args.folder and args.send_email:
result_path = os.path.join(caliper_path.folder_ope.workspace, caliper_path.folder_ope.name,
'results_summary.log')
if os.path.exists(result_path):
send_mails.send_mails(result_path)
print("\n'results_summary.log' file has been sent, please check the mail\n")
sys.exit()
if not os.path.exists(result_path):
try:
os.makedirs(caliper_path.folder_ope.workspace)
except Exception as e:
print("\nCan't able to send the mail as 'results_summary.log' file is not present\n ")
sys.exit()

if not args.folder and args.send_email:
result_path = os.path.join(caliper_path.folder_ope.workspace, caliper_path.folder_ope.name,
'results_summary.log')
if os.path.exists(result_path):
send_mails.send_mails(result_path)
print("\n'results_summary.log' file has been sent , please check the mail\n")
sys.exit()
if not os.path.exists(result_path):
try:
os.makedirs(caliper_path.folder_ope.workspace)
except Exception as e:
print("\n Can't able to send the mail as 'results_summary.log' file is not present\n ")
sys.exit()

if not args.webpage and args.send_email:
current_path = os.getcwd()
Expand Down
4 changes: 4 additions & 0 deletions client/shared/send_mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Desc :

import os
import HTMLParser
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
Expand Down Expand Up @@ -56,6 +57,7 @@ def getContext(self):
msg['Subject'] = self.subject
msg['From'] = self.fro
msg['To'] = ','.join(self.to)
msg['plaintext'] = self.plaintext
msg.preamble = 'This is a multi-part message in MIME format'
msgAlternative = MIMEMultipart('alternative')
msg.attach(msgAlternative)
Expand Down Expand Up @@ -90,6 +92,8 @@ def send_mail(self, auth, email):
# set the debug level
# smtp.set_debuglevel(1)
smtp.connect(auth.server)
smtp.starttls()
smtp.ehlo()
smtp.login(auth.user, auth.password)
smtp.sendmail(email.fro, email.to, email.getContext())
smtp.quit()
Expand Down

0 comments on commit 04ab55c

Please sign in to comment.