Пример #1
0
def send_fetions(admin, path):
	fetions = Sms.objects.filter(sent = False, fetion_or_zuitu = True)
	if len(fetions) == 0:
		return
		
	file(path, "wb")
	p = fetion_login(admin)
	if p == None:
		os.remove(path)
		print datetime.datetime.now().__str__() + "\tlogin error"
		return
		
	sent_count = 0
	for fetion in fetions:
		if send_fetion(admin, p, fetion) == False:
			send_zuitu(fetion.mobile, fetion.message)
			send_zuitu(admin.mobile, "fetion is down")
			print datetime.datetime.now().__str__() + "\tsend error"
			os.remove(path)
			return
		fetion.sent = True
		fetion.save()
		sent_count += 1
		time.sleep(1)
	print datetime.datetime.now().__str__() + "\t%s fetions sent"%sent_count
	os.remove(path)
Пример #2
0
def send_zuitus(admin, path):
	zuitus = Sms.objects.filter(sent = False, fetion_or_zuitu = False)
	if len(zuitus) == 0:
		return

	file(path, "wb")
	sent_count = 0
	for zuitu in zuitus:
		send_zuitu(zuitu.mobile, zuitu.message)
		zuitu.sent = True
		zuitu.save()
		sent_count += 1
	print datetime.datetime.now().__str__() + "\t%s zuitus sent"%sent_count
	os.remove(path)