コード例 #1
0
ファイル: send_tools.py プロジェクト: ashhher3/Analysis
def send_email_with_file(addressee, text, subject, file_list):
    """发送file email"""

    msg = MIMEMultipart()
    msg.attach(MIMEText(text, _charset='utf-8'))
    msg['Subject'] = Header(subject, 'utf-8')
    msg['From'] = '*****@*****.**'
    msg['To'] = addressee

    for file_name in file_list:
        ctype, encoding = mimetypes.guess_type(file_name)
        if ctype is None or encoding is not None:
            ctype = 'application/octet-stream'
        maintype, subtype = ctype.split('/', 1)
        
        attachment = MIMEImage((lambda f: (f.read(), f.close())) \
                (open(file_name, 'rb'))[0], _subtype =subtype)
        attachment.add_header('Content-Disposition', 'attachment', filename=file_name)
        msg.attach(attachment)

    try:
        smtp = smtplib.SMTP()
        smtp.connect('smtp.ym.163.com', 25) 
        smtp.login(msg['From'], 'zhoujb.19890211') 
        smtp.sendmail(msg['From'], addressee, msg.as_string())
    except Exception,e:
        logger.exception('send_email: %s' % (str(e)))
コード例 #2
0
def send_email_with_file(addressee, text, subject, file_list):
    """发送file email"""

    msg = MIMEMultipart()
    msg.attach(MIMEText(text, _charset='utf-8'))
    msg['Subject'] = Header(subject, 'utf-8')
    msg['From'] = '*****@*****.**'
    msg['To'] = addressee

    for file_name in file_list:
        ctype, encoding = mimetypes.guess_type(file_name)
        if ctype is None or encoding is not None:
            ctype = 'application/octet-stream'
        maintype, subtype = ctype.split('/', 1)

        attachment = MIMEImage((lambda f: (f.read(), f.close())) \
                (open(file_name, 'rb'))[0], _subtype =subtype)
        attachment.add_header('Content-Disposition',
                              'attachment',
                              filename=file_name)
        msg.attach(attachment)

    try:
        smtp = smtplib.SMTP()
        smtp.connect('smtp.ym.163.com', 25)
        smtp.login(msg['From'], 'zhoujb.19890211')
        smtp.sendmail(msg['From'], addressee, msg.as_string())
    except Exception, e:
        logger.exception('send_email: %s' % (str(e)))
コード例 #3
0
def daily_update_script():
    """更新user_center 并将更新导入到百会CRM"""
    logger.info('user_center update start')
    try:
        user_obj = UserCenter(['ts-1796606'])
        user_obj.collect_online_info()
        user_obj.collect_update_info()
        user_obj.write_baihui_info()
        user_obj.update_online()
    except Exception, e:
        logger.exception('user_center update error: %s', str(e))
        send_sms('13738141586', 'user_center update error: ' + str(e))
コード例 #4
0
def daily_update_script():
    """更新user_center 并将更新导入到百会CRM"""
    logger.info('user_center update start') 
    try:
        user_obj = UserCenter(['ts-1796606'])
        user_obj.collect_online_info()
        user_obj.collect_update_info()
        user_obj.write_baihui_info()
        user_obj.update_online()
    except Exception,e:
        logger.exception('user_center update error: %s', str(e))
        send_sms('13738141586', 'user_center update error: '+str(e))
コード例 #5
0
def analysis_ztc_order_script():
    ToMe = '*****@*****.**'
    ToAll = '*****@*****.**'
    try:
        ztc = ZtcOrderReport()
        ztc.make_report()
        ztc.write_report()
        html = ztc.getHtml()
        #send_email_with_html(ToMe, html, str(datetime.date.today())+'__直通车软件报表内侧版')
        send_email_with_html(ToAll, html, str(datetime.date.today())+'__直通车软件报表公测版')
    except Exception,e:
        logger.exception('analysis_ztc_order_script error: %s' % (str(e)))
        send_sms('13738141586', 'analysis_ztc_order_script error: '+str(e))
コード例 #6
0
ファイル: send_tools.py プロジェクト: ashhher3/Analysis
def send_email_with_text(addressee, text, subject):
    """发送文本email"""

    msg = MIMEMultipart()
    msg.attach(MIMEText(text, _charset='utf-8'))
    msg['Subject'] = Header(subject, 'utf-8')
    msg['From'] = '*****@*****.**'
    msg['To'] = addressee
    try:
        smtp = smtplib.SMTP()
        smtp.connect('smtp.ym.163.com', 25) 
        smtp.login(msg['From'], 'zhoujb.19890211')                                                                       
        smtp.sendmail(msg['From'], msg['To'], msg.as_string())
    except Exception,e:
        logger.exception('send_email: %s' % (str(e)))
コード例 #7
0
def analysis_campaign_script():
    today = str(datetime.date.today())
    syb_file = CURRENT_DIR+'data/report_data/syb_report' + today + '.csv'
    bd_file = CURRENT_DIR+'data/report_data/bd_report' + today + '.csv'
    if not os.path.exists(syb_file):
        logger.error('analysis_campaign error: %s not exists ' % (syb_file))
        return None
    try:
        content = analysis_campaign(syb_file, bd_file)
        #send_email_with_text('*****@*****.**', content, today+'_产品报表日常分析')
        send_email_with_text('*****@*****.**', content, today+'_产品报表日常分析')

    except Exception,e:
        logger.exception('analysis_campaign error: %s' % (str(e)))
        send_sms('13738141586', 'analysis_campaign error: %s' % (str(e)))
コード例 #8
0
def send_email_with_text(addressee, text, subject):
    """发送文本email"""

    msg = MIMEMultipart()
    msg.attach(MIMEText(text, _charset='utf-8'))
    msg['Subject'] = Header(subject, 'utf-8')
    msg['From'] = '*****@*****.**'
    msg['To'] = addressee
    try:
        smtp = smtplib.SMTP()
        smtp.connect('smtp.ym.163.com', 25)
        smtp.login(msg['From'], 'zhoujb.19890211')
        smtp.sendmail(msg['From'], msg['To'], msg.as_string())
    except Exception, e:
        logger.exception('send_email: %s' % (str(e)))
コード例 #9
0
def send_email_with_html(addressee, html, subject):
    """发送html email"""

    msg = MIMEMultipart()
    msg['Subject'] = subject
    msg['From'] = '*****@*****.**'
    msg['To'] = addressee
    html_att = MIMEText(html, 'html', 'utf-8')
    msg.attach(html_att)
    try:
        smtp = smtplib.SMTP()
        smtp.connect('smtp.ym.163.com', 25) 
        smtp.login(msg['From'], 'zhoujb.19890211')                                                                       
        smtp.sendmail(msg['From'], msg['To'], msg.as_string())
    except Exception,e:
        logger.exception('send_email: %s' % (str(e)))
コード例 #10
0
def analysis_campaign_script():
    today = str(datetime.date.today())
    report_file = CURRENT_DIR+'data/report_data/report' + today + '.csv'
    if not os.path.exists(report_file):
        logger.error('analysis_campaign error: %s not exists ' % (report_file))
        return None
    try:
        content = analysis_campaign(report_file)
        sendTo = ['*****@*****.**', '*****@*****.**', \
            '*****@*****.**', '*****@*****.**']
        #for send_to in sendTo:
        #    send_email_with_text(send_to, content, today+'_省油宝日常分析')
        send_email_with_text('*****@*****.**', content, today+'_省油宝日常分析')
    except Exception,e:
        logger.exception('analysis_campaign error: %s' % (str(e)))
        send_sms('13738141586', 'analysis_campaign error: %s' % (str(e)))
コード例 #11
0
def monitor_soft_script():
    try:
        return_info = monitor_soft() 
    except Exception,e:
        logger.exception('monitor_soft error: %s', str(e))
        send_sms('13738141586', 'monitor_soft_script error: '+str(e))
コード例 #12
0
ファイル: send_self_order.py プロジェクト: ashhher3/Analysis
from CommonTools.send_tools import send_email_with_file, send_sms


def send_add_order_and_support():
    """发送每日新增订单与服务支持"""

    merge_order = []
    merge_support = []
    order_head = CURRENT_DIR + "data/order_head.csv"
    support_head = CURRENT_DIR + "data/support_head.csv"
    send_order = CURRENT_DIR + "data/new_order.csv"
    send_support = CURRENT_DIR + "data/new_support.csv"

    merge_order.append(CURRENT_DIR + "data/order.csv")
    merge_support.append(CURRENT_DIR + "data/support.csv")
    os.system("cat %s %s > %s" % (order_head, " ".join(merge_order), send_order))
    os.system("cat %s %s > %s" % (support_head, " ".join(merge_support), send_support))

    subject = "昨日新增订单测试版"
    content = "支持专属客服,注意,订单抓取现在使用新脚本且近期订单API抽风的可能性比较大,请事先认真核对下再导入到百会CRM。\n有问题和不明确的请及时反馈"
    send_email_with_file("*****@*****.**", content, subject, [send_order, send_support])
    # send_email_with_file('*****@*****.**', content, subject, [send_order, send_support])


if __name__ == "__main__":
    try:
        send_add_order_and_support()
    except Exception, e:
        logger.exception("send_add_order_and_support error: %s", str(e))
        send_sms("send_add_order_and_support error:%s" % (str(e)))
コード例 #13
0
def send_add_order_and_support():
    """发送每日新增订单与服务支持"""

    merge_order = []
    merge_support = []
    order_head = CURRENT_DIR + 'data/order_head.csv'
    support_head = CURRENT_DIR + 'data/support_head.csv'
    send_order = CURRENT_DIR + 'data/new_order.csv'
    send_support = CURRENT_DIR + 'data/new_support.csv'

    merge_order.append(CURRENT_DIR + 'data/order.csv')
    merge_support.append(CURRENT_DIR + 'data/support.csv')
    os.system('cat %s %s > %s' %
              (order_head, ' '.join(merge_order), send_order))
    os.system('cat %s %s > %s' %
              (support_head, ' '.join(merge_support), send_support))

    subject = '昨日新增订单测试版'
    content = '支持专属客服,注意,订单抓取现在使用新脚本且近期订单API抽风的可能性比较大,请事先认真核对下再导入到百会CRM。\n有问题和不明确的请及时反馈'
    send_email_with_file('*****@*****.**', content, subject,
                         [send_order, send_support])
    #send_email_with_file('*****@*****.**', content, subject, [send_order, send_support])


if __name__ == '__main__':
    try:
        send_add_order_and_support()
    except Exception, e:
        logger.exception('send_add_order_and_support error: %s', str(e))
        send_sms('send_add_order_and_support error:%s' % (str(e)))
コード例 #14
0
def monitor_soft_script():
    try:
        return_info = monitor_soft()
    except Exception, e:
        logger.exception('monitor_soft error: %s', str(e))
        send_sms('13738141586', 'monitor_soft_script error: ' + str(e))