Esempio n. 1
0
def sms2gate(): 

    count = 0
    now = datetime.datetime.now()
    sms_list = SmsSend.objects.not_send_yet_sms2gate()
    sms_list = sms_list.filter(is_in_queue=False)[0:1000]

    if sms_list:
        #sendclient = send()
        for record in sms_list:
            try:
                record.is_in_queue = True
                record.save()
            except:
                pass
            data = {"id":record.id}
#             payload = urllib.urlencode(data)
            #print payload,"========"
            try:
                res = URL('http://' + SITE_INFO.domain + reverse('cron_push_sms_send')).post_async(id=record.id)
#                queue.sms2gate.delay(data)
#                 queue = TaskQueue('sms2gate')
#                 queue.add(Task("/backend/taskqueue/sms2gate",payload))
                count+=1
            except:
                st = SmsSendTrans()
                st.sms_send_to_gate(record.id)
            #print record.receive_mobile

    result = "total push sms2gate:"+str(count)
    return result
Esempio n. 2
0
def sms2gate(request): 

    count = 0
    now = datetime.datetime.now()
    sms_list = SmsSend.objects.not_send_yet_sms2gate()[0:1000]
    
    if sms_list:
        #sendclient = send()
        for record in sms_list:

            data = {"id":record.id}
#             payload = urllib.urlencode(data)
            #print payload,"========"
            try:
#                 queue.sms2gate.delay(data)
                queue = TaskQueue('sms2gate')
                queue.add(Task("/backend/taskqueue/sms2gate",payload))
                count+=1
            except:
                st = SmsSendTrans()
                st.sms_send_to_gate(record.id)
            #print record.receive_mobile

    result = "total push message:"+str(count)
    return HttpResponse(result)
Esempio n. 3
0
def sms2gate(data):
    
    status = False
    now = datetime.datetime.now()
    result = 0
    try:
        id = data['id']
        st = SmsSendTrans()
        result = st.sms_send_to_gate(id)
        status = st._msg
    except Exception, e:
        print e
Esempio n. 4
0
def sms2gate(request):
    print 'sms2gate...........'
    status = False
    now = datetime.datetime.now()
    result = 0
    try:
        id = request.REQUEST.get('id')
        st = SmsSendTrans()
        result = st.sms_send_to_gate(id)
        status = st._msg
    except Exception, e:
        print e
#        return HttpResponse(e)
        status = ''