2018-08-29 11:19:13 +00:00
|
|
|
# coding=utf-8
|
|
|
|
import datetime
|
|
|
|
import wrapcache
|
|
|
|
|
|
|
|
from config.TicketEnmu import ticket
|
|
|
|
|
|
|
|
|
|
|
|
class checkUser:
|
|
|
|
def __init__(self, session):
|
|
|
|
self.session = session
|
|
|
|
|
|
|
|
def sendCheckUser(self):
|
|
|
|
"""
|
2018-09-30 06:35:27 +00:00
|
|
|
检查用户登录, 检查间隔为2分钟
|
2018-08-29 11:19:13 +00:00
|
|
|
:return:
|
|
|
|
"""
|
2018-12-31 04:22:37 +00:00
|
|
|
CHENK_TIME = 0.3
|
2018-08-29 11:19:13 +00:00
|
|
|
if wrapcache.get("user_time") is None:
|
|
|
|
check_user_url = self.session.urls["check_user_url"]
|
|
|
|
data = {"_json_att": ""}
|
|
|
|
check_user = self.session.httpClint.send(check_user_url, data)
|
|
|
|
if check_user.get("data", False):
|
|
|
|
check_user_flag = check_user["data"]["flag"]
|
|
|
|
if check_user_flag is True:
|
2018-09-30 06:35:27 +00:00
|
|
|
wrapcache.set("user_time", datetime.datetime.now(), timeout=60 * CHENK_TIME)
|
2018-08-29 11:19:13 +00:00
|
|
|
else:
|
|
|
|
if check_user['messages']:
|
|
|
|
print (ticket.LOGIN_SESSION_FAIL.format(check_user['messages']))
|
|
|
|
self.session.call_login()
|
2018-09-30 06:35:27 +00:00
|
|
|
wrapcache.set("user_time", datetime.datetime.now(), timeout=60 * CHENK_TIME)
|
2018-08-29 11:19:13 +00:00
|
|
|
else:
|
|
|
|
print (ticket.LOGIN_SESSION_FAIL.format(check_user['messages']))
|
|
|
|
self.session.call_login()
|
2018-09-30 06:35:27 +00:00
|
|
|
wrapcache.set("user_time", datetime.datetime.now(), timeout=60 * CHENK_TIME)
|