def sms2send(data): result = False try: sms_id = data['sms_id'] st = SmsTrans() st.kinger_sms_to_sms(sms_id) result = st._msg except Exception, e: print e
def sms2send(request): print 'sms2send...........' resust = False try: sms_id = request.REQUEST.get('sms_id') st = SmsTrans() st.kinger_sms_to_sms(sms_id) result = st._msg except Exception, e: print e result = ''
def sms2send(): """ 转换并发送 """ convert_count = 0 send_count = 0 now = datetime.datetime.now() k_sms_list = Sms.objects.not_send_yet_sms()[0:1000] # def get_test_sms(mobile=u'15814020825'): # sms = Sms.objects.all()[0] # sms.mobile = mobile # return [sms] # sms_list = get_test_sms() if k_sms_list: for record in k_sms_list: convert_count+=1 id = record.id data = {"sms_id":id} # payload = urllib.urlencode(data) #执行转换 try: res = URL('http://' + SITE_INFO.domain + reverse('cron_sms2send')).post_async(sms_id=id) # queue.sms2send.delay(data) # print '+++++++++++' # queue = TaskQueue('sms2send') # queue.add(Task("/backend/taskqueue/sms2send",payload)) except: st = SmsTrans() st.kinger_sms_to_sms(id) print '-------------' result = "成功转换 "+str(convert_count) return result
def sms2send(request): """ 转换并发送 """ convert_count = 0 send_count = 0 now = datetime.datetime.now() k_sms_list = Sms.objects.not_send_yet_sms()[0:1000] # def get_test_sms(mobile=u'15814020825'): # sms = Sms.objects.all()[0] # sms.mobile = mobile # return [sms] # sms_list = get_test_sms() if k_sms_list: for record in k_sms_list: convert_count+=1 id = record.id data = {"sms_id":id} # payload = urllib.urlencode(data) #执行转换 try: # queue.sms2send.delay(data) # print '+++++++++++' queue = TaskQueue('sms2send') queue.add(Task("/backend/taskqueue/sms2send",payload)) except: st = SmsTrans() st.kinger_sms_to_sms(id) print '-------------' result = "成功转换 "+str(convert_count) return HttpResponse(result)