def collect_order_script(_days=0):
    today = datetime.date.today() - datetime.timedelta(days=_days)
    try:
        ztc = ZtcOrderCollect(today)
        ztc.get_order()
        ztc.write_order()
    except Exception,e:
        logger.error('collect_order_script %s: %s' % (str(today), str(e)))
        send_sms('13738141586', 'collect_order_script %s: %s' % (str(today), str(e)))
예제 #2
0
def collect_order_script(_days=0):
    today = datetime.date.today() - datetime.timedelta(days=_days)
    try:
        ztc = ZtcOrderCollect(today)
        ztc.get_order()
        ztc.write_order()
    except Exception,e:
        logger.error('collect_order_script %s: %s' % (str(today), str(e)))
        send_sms('13738141586', 'collect_order_script %s: %s' % (str(today), str(e)))
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)))
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)))
예제 #5
0
def send_sms(cellphone, text, retry_times=3):
    """发送短信"""

    retry_times -= 1
    if retry_times < 0:
        logger.error('send message to %s unsuccessfully' % (cellphone, ))
        return
    dict = {}
    dict['command'] = SEND_COMMAND
    dict['spid'] = SPID
    dict['sppassword'] = SP_PASSWORD
    dict['da'] = '86' + cellphone
    dict['dc'] = DC
    dict['sm'] = _toHex(text, 'gbk')
    url_params = urllib.urlencode(dict)
    try:
        response = urllib2.urlopen(SEND_MSG_URL, url_params)
        dict = _parse_sms_response(response.read())
        if dict.get('mterrcode', None) != '000':
            logger.error('send message to %s unsuccessfully:response error' %
                         (cellphone, ))
            send_sms(cellphone, text, retry_times)
    except urllib2.HTTPError, e:
        logger.error('send message to %s unsuccessfully:url connect error' %
                     (cellphone, ))
        send_sms(cellphone, text, retry_times)
예제 #6
0
def send_sms(cellphone, text, retry_times=3):
    """发送短信"""

    retry_times -= 1
    if retry_times < 0:
        logger.error('send message to %s unsuccessfully'%(cellphone,))
        return
    dict = {}
    dict['command'] = SEND_COMMAND
    dict['spid'] = SPID
    dict['sppassword'] = SP_PASSWORD
    dict['da'] = '86'+cellphone
    dict['dc'] = DC 
    dict['sm']  = _toHex(text,'gbk')
    url_params = urllib.urlencode(dict)
    try:
        response = urllib2.urlopen(SEND_MSG_URL,url_params)
        dict = _parse_sms_response(response.read())
        if dict.get('mterrcode',None) != '000':
            logger.error('send message to %s unsuccessfully:response error'%(cellphone,))
            send_sms(cellphone,text,retry_times)
    except urllib2.HTTPError,e:
        logger.error('send message to %s unsuccessfully:url connect error'%(cellphone,))
        send_sms(cellphone,text,retry_times)
예제 #7
0
def send_sms(cellphone, text, retry_times=3):
    """发送短信"""

    retry_times -= 1
    if retry_times < 0:
        logger.error('send message to %s unsuccessfully'%(cellphone,))
        return
    dict = {}
    dict['command'] = SEND_COMMAND
    dict['spid'] = SPID
    dict['sppassword'] = SP_PASSWORD
    dict['da'] = '86'+cellphone
    dict['dc'] = DC 
    dict['sm']  = _toHex(text,'gbk')
    url_params = urllib.urlencode(dict)
    try:
        response = urllib2.urlopen(SEND_MSG_URL,url_params)
        dict = _parse_sms_response(response.read())
        if dict.get('mterrcode',None) != '000':
            logger.error('send message to %s unsuccessfully:response error'%(cellphone,))
            send_sms(cellphone,text,retry_times)
    except urllib2.HTTPError,e:
        logger.error('send message to %s unsuccessfully:url connect error'%(cellphone,))
        send_sms(cellphone,text,retry_times)
    except Exception,e:
        logger.error('send message to %s unsuccessfully:server error'%(cellphone,))
        send_sms(cellphone,text,retry_times)

if __name__ == '__main__':
    send_email_with_text('*****@*****.**', 'text', 'subject')
예제 #8
0
    if retry_times < 0:
        logger.error('send message to %s unsuccessfully' % (cellphone, ))
        return
    dict = {}
    dict['command'] = SEND_COMMAND
    dict['spid'] = SPID
    dict['sppassword'] = SP_PASSWORD
    dict['da'] = '86' + cellphone
    dict['dc'] = DC
    dict['sm'] = _toHex(text, 'gbk')
    url_params = urllib.urlencode(dict)
    try:
        response = urllib2.urlopen(SEND_MSG_URL, url_params)
        dict = _parse_sms_response(response.read())
        if dict.get('mterrcode', None) != '000':
            logger.error('send message to %s unsuccessfully:response error' %
                         (cellphone, ))
            send_sms(cellphone, text, retry_times)
    except urllib2.HTTPError, e:
        logger.error('send message to %s unsuccessfully:url connect error' %
                     (cellphone, ))
        send_sms(cellphone, text, retry_times)
    except Exception, e:
        logger.error('send message to %s unsuccessfully:server error' %
                     (cellphone, ))
        send_sms(cellphone, text, retry_times)


if __name__ == '__main__':
    send_email_with_text('*****@*****.**', 'text', 'subject')