<commit_before>#!/usr/bin/python
'''
    supersid_plot
    version: 1.3.1 enhanced for Python 2.7 and 3.3
    Original Copyright: Stanford Solar Center - 2008
    Copyright: <NAME> - 2012


    Support one to many files as input, even in Drag & Drop
    Draw multi-stations graphs
    Offer the possibility to generate PDF and email it (perfect for batch mode)
    Offer the possibility to fetch NOAA XRA data and add them on the plot

'''
from __future__ import print_function   # use the new Python 3 'print' function
import sys
import datetime, time
import itertools
import os.path
import glob
# matplolib tools
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter as ff
from matplotlib.backends.backend_pdf import PdfPages
import matplotlib.dates
# Internet and Email modules
import smtplib
try:  # python 2.7 vs. Python 3.3
    import urllib2
    from email.MIMEText import MIMEText
except ImportError:
    import urllib.request, urllib.error
    from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders
import argparse
# SuperSID modules
from sidfile import SidFile
from config import Config

def sendMail(config, To_mail, msgBody, PDFfile):
    """Send the mail using the smtplib module
       The plot (as PDF) attached"""
    senderEmail = config.get("from_mail","")
    mailserver = config.get("email_server","")
    mailserveruser = config.get("email_login","")          # <-- set to None if no login required
    mailserverpasswd = config.get("email_password","")     # <-- set to None if no login required

    # create the mail message
    msg = MIMEMultipart(_subtype='html')
    msg['Subject'] = 'Auto-generated eMail from SuperSID'
    msg.attach( MIMEText(msgBody) )

    # Following headers are useful to show the email correctly
    msg['From'] = senderEmail
    msg['Reply-to'] = senderEmail
    msg['To'] = To_mail

    # attach the PDF file
    ctype, encoding = ('application/pdf', None)
    maintype, subtype = ctype.split('/', 1)
    with open(PDFfile, 'rb') as pdf:
        att = MIMEBase(maintype, subtype)
        att.set_payload(pdf.read())
        encoders.encode_base64(att)
        att.add_header('Content-Disposition', 'attachment', filename=PDFfile)
        msg.attach(att)

    # Establish an SMTP object by connecting to your mail server
    s = smtplib.SMTP()
    s.connect(mailserver)
    if mailserveruser: s.login(mailserveruser, mailserverpasswd)
    # Send the email - real from, real to, extra headers and content ...
    s.sendmail(senderEmail, To_mail, msg.as_string())
    s.close()<commit_msg>date in email<commit_after>#!/usr/bin/python
'''
    supersid_plot
    version: 1.3.1 enhanced for Python 2.7 and 3.3
    Original Copyright: Stanford Solar Center - 2008
    Copyright: <NAME> - 2012


    Support one to many files as input, even in Drag & Drop
    Draw multi-stations graphs
    Offer the possibility to generate PDF and email it (perfect for batch mode)
    Offer the possibility to fetch NOAA XRA data and add them on the plot

'''
from __future__ import print_function   # use the new Python 3 'print' function
import sys
import datetime, time
import itertools
import os.path
import glob
# matplolib tools
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter as ff
from matplotlib.backends.backend_pdf import PdfPages
import matplotlib.dates
# Internet and Email modules
import smtplib
try:  # python 2.7 vs. Python 3.3
    import urllib2
    from email.MIMEText import MIMEText
except ImportError:
    import urllib.request, urllib.error
    from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email import encoders, utils
import argparse
# SuperSID modules
from sidfile import SidFile
from config import Config

def sendMail(config, To_mail, msgBody, PDFfile):
    """Send the mail using the smtplib module
       The plot (as PDF) attached"""
    senderEmail = config.get("from_mail","")
    mailserver = config.get("email_server","")
    mailserveruser = config.get("email_login","")          # <-- set to None if no login required
    mailserverpasswd = config.get("email_password","")     # <-- set to None if no login required

    # create the mail message
    msg = MIMEMultipart(_subtype='html')
    msg['Subject'] = 'Auto-generated eMail from SuperSID'
    msg.attach( MIMEText(msgBody) )

    # Following headers are useful to show the email correctly
    msg['From'] = senderEmail
    msg['Reply-to'] = senderEmail
    msg['To'] = To_mail
    msg['Date'] = utils.formatdate(localtime = 1)

    # attach the PDF file
    ctype, encoding = ('application/pdf', None)
    maintype, subtype = ctype.split('/', 1)
    with open(PDFfile, 'rb') as pdf:
        att = MIMEBase(maintype, subtype)
        att.set_payload(pdf.read())
        encoders.encode_base64(att)
        att.add_header('Content-Disposition', 'attachment', filename=PDFfile)
        msg.attach(att)

    # Establish an SMTP object by connecting to your mail server
    s = smtplib.SMTP()
    s.connect(mailserver)
    if mailserveruser: s.login(mailserveruser, mailserverpasswd)
    # Send the email - real from, real to, extra headers and content ...
    s.sendmail(senderEmail, To_mail, msg.as_string())
    s.close()
{'fraction_non_alphanumeric': 0.0898080864542575, 'fraction_numerical': 0.00912986771008012, 'mean_word_length': 3.549152542372881, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4594201', 'n_tokens_mistral': 1641, 'n_tokens_neox': 1599, 'n_words': 557}