本文整理汇总了Python中helpers.queryhelper.QueryHelper.get_cnum_by_terminal方法的典型用法代码示例。如果您正苦于以下问题:Python QueryHelper.get_cnum_by_terminal方法的具体用法?Python QueryHelper.get_cnum_by_terminal怎么用?Python QueryHelper.get_cnum_by_terminal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpers.queryhelper.QueryHelper
的用法示例。
在下文中一共展示了QueryHelper.get_cnum_by_terminal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_new_login
# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_cnum_by_terminal [as 别名]
def handle_new_login(t_info, address, connection, channel, exchange, gw_binding, db, redis):
"""Handle the login packet with version bigger than 2.2.0
S1
t_info:{'dev_id' // tid
't_msisdn' // tmobile
'u_msisdn' // umobile
'imei' // sim's id
'imsi' // track's id
'dev_type'
'softversion' // version of terminal, like 2.3.0
'timestamp'
'psd'
'keys_num'
'sessionID'
'command'
'factory_name'
}
flag(t_info['psd']):
0 - boot_normally
1 - active_terminal
2 - assert_reboot
3 - network_uncovered
4 - server_no_response
5 - config_changed
6 - session_expired
7 - terminal_unactived
8 - package_send_fail
9 - simcard_error
10 - gprs_error
11 - mcu_timeout
12 - reboot_by_sms
100 - script_reload
workflow:
if normal login:
if sn and imsi exist, but msisdn and msisdn are empty:
send register sms again
normal login, check [SN,PHONE,IMSI,USER] is matching or not.
else: #JH
delete old bind relation of tid, and send message to old user.
update new bind relation of tmobile, and send message to new user.
login response packet:
0 - success, then get a sessionID for terminal and record terminal's address
1 - unregister, terminal login first.
3 - illegal sim, a mismatch between [SN,PHONE,IMSI,USER]
6 - not whitelist
"""
args = DotDict(success=GATEWAY.LOGIN_STATUS.SUCCESS,
sessionID='')
tid = t_info.dev_id
resend_key, resend_flag = get_resend_flag(redis, tid, t_info.timestamp, t_info.command)
sms = ''
t_status = None
#NOTE: new softversion, new meaning, 1: active; othter: normal login
flag = t_info['psd']
terminal = db.get("SELECT tid, group_id, mobile, imsi, owner_mobile, service_status,"
" defend_status, mannual_status, icon_type, login_permit, "
" alias, vibl, use_scene, push_status, speed_limit, stop_interval,"
" distance_current"
" FROM T_TERMINAL_INFO"
" WHERE mobile = %s LIMIT 1",
t_info['t_msisdn'])
cnum = QueryHelper.get_cnum_by_terminal(tid, t_info['t_msisdn'], redis, db)
#NOTE: normal login
if flag != "1": # normal login
#NOTE: no tmobile and ower_mobile
if (not t_info['t_msisdn']) and (not t_info['u_msisdn']):
t = db.get("SELECT tid, group_id, mobile, imsi, owner_mobile, service_status"
" FROM T_TERMINAL_INFO"
" WHERE service_status=1"
" AND tid = %s "
" AND imsi = %s LIMIT 1",
t_info['dev_id'], t_info['imsi'])
if t:
args.success = GATEWAY.LOGIN_STATUS.ILLEGAL_SIM
t_info['t_msisdn'] = t.mobile
t_info['u_msisdn'] = t.owner_mobile
register_sms = SMSCode.SMS_REGISTER % (t.owner_mobile, t.mobile)
SMSHelper.send_to_terminal(t.mobile, register_sms)
logging.info("[GW] A crash terminal tid:%s, imei:%s has no tmobile: %s, umobile:%s in login packet, so send %s again.",
t_info['dev_id'], t_info['imei'], t_info['t_msisdn'], t_info['u_msisdn'], register_sms)
else:
args.success = GATEWAY.LOGIN_STATUS.ILLEGAL_SIM
logging.info("[GW] A crash terminal:%s login without umobile and tmobile, and there is no record in db.", t_info['dev_id'])
else:
#NOTE: no tmobile
if not t_info['t_msisdn']:
# login first.
tid_terminal = db.get("SELECT tid, mobile, owner_mobile, service_status"
" FROM T_TERMINAL_INFO"
" WHERE tid = %s LIMIT 1", t_info['dev_id'])
args.success = GATEWAY.LOGIN_STATUS.ILLEGAL_SIM
#.........这里部分代码省略.........