<s> import argparse <EOL> import smtplib <EOL> import os <EOL> import getpass <EOL> from email . mime . text import MIMEText <EOL> import sys <EOL> sys . path . insert ( <NUM_LIT:0> , '<STR_LIT:..>' ) <EOL> from conf import work_dir <EOL> from options import cfg2dict <EOL> from build_template import _from_template <EOL> args = None <EOL> password = None <EOL> def parse_args ( ) : <EOL> parser = argparse . ArgumentParser ( description = "<STR_LIT>" ) <EOL> parser . add_argument ( '<STR_LIT>' , action = '<STR_LIT:store_true>' ) <EOL> parser . add_argument ( '<STR_LIT>' , default = None ) <EOL> global args <EOL> args = parser . parse_args ( ) <EOL> args . dry_run = not args . send <EOL> if args . dry_run : <EOL> print '<STR_LIT>' <EOL> return args <EOL> def load_config ( conf_file ) : <EOL> return cfg2dict ( conf_file ) <EOL> def get_password ( sender ) : <EOL> global password <EOL> if not args . dry_run and not password : <EOL> password = getpass . getpass ( sender + "<STR_LIT>" ) <EOL> def email_addr_from ( name_email ) : <EOL> return '<STR_LIT>' % ( name_email [ '<STR_LIT:name>' ] , name_email [ '<STR_LIT:email>' ] ) <EOL> def send_template ( sender , recipient , template , template_data , <EOL> smtp_server = '<STR_LIT>' , smtp_port = <NUM_LIT> ) : <EOL> if args . dry_run : <EOL> print '<STR_LIT>' % recipient <EOL> else : <EOL> get_password ( sender [ '<STR_LIT>' ] ) <EOL> print '<STR_LIT>' % recipient <EOL> template_data [ '<STR_LIT:email>' ] = recipient <EOL> message = _from_template ( '<STR_LIT>' + template , template_data ) <EOL> if args . dry_run : <EOL> print "<STR_LIT:=>" * <NUM_LIT> <EOL> print message <EOL> print "<STR_LIT:=>" * <NUM_LIT> <EOL> return <EOL> session = smtplib . SMTP ( smtp_server , smtp_port ) <EOL> session . ehlo ( ) <EOL> session . starttls ( ) <EOL> session . ehlo <EOL> session . login ( sender [ '<STR_LIT>' ] , password ) <EOL> session . sendmail ( sender [ '<STR_LIT:name>' ] , recipient , message ) <EOL> session . quit ( ) </s>
