rabin 7 years ago
parent
commit
79657abbad
1 changed files with 19 additions and 0 deletions
  1. 19 0
      cron.py

+ 19 - 0
cron.py

@@ -26,8 +26,12 @@ def device():
 			model.id = v['id']
 			if v['hardware_type'] == 5:
 				model.update(value='0', status=False)
+				#提醒notice
+				notice(2, v)
 			elif v['hardware_type'] != 7 and v['hardware_type'] != 6:
 				model.update(status=False)
+				#提醒notice
+				notice(2, v)
 		gevent.sleep(60)
 
 def savePic():
@@ -44,11 +48,26 @@ def timeSync():
 		pub.push(key, value)
 		gevent.sleep(3600*24)
 
+# 用户一周没有使用的时候提醒
+def userNotice():
+	while 1:
+		model = Demeter.model('farm_user')
+		cur = Demeter.time() - 3600*24*7
+		model.cdate.assgin(cur, '<=')
+		model.status = True
+		data = model.select()
+		for v in data:
+			notice(1, data)
+
+# 用户提醒
+def notice(t, data):
+
 def handle():
 	gevent.joinall([
 		gevent.spawn(device),
 		#gevent.spawn(savePic),
 		gevent.spawn(timeSync),
+		gevent.spawn(userNotice),
 	])
 
 handle()