本文整理汇总了Python中helpers.queryhelper.QueryHelper.get_user_by_tmobile方法的典型用法代码示例。如果您正苦于以下问题:Python QueryHelper.get_user_by_tmobile方法的具体用法?Python QueryHelper.get_user_by_tmobile怎么用?Python QueryHelper.get_user_by_tmobile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpers.queryhelper.QueryHelper
的用法示例。
在下文中一共展示了QueryHelper.get_user_by_tmobile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_user_by_tmobile [as 别名]
def post(self):
"""Reregist a pair of umobile and tmobile.
Send sms to terminal.
"""
status = ErrorCode.SUCCESS
try:
data = DotDict(json_decode(self.request.body))
logging.info("[UWEB] Register request: %s", data)
except Exception as e:
status = ErrorCode.ILLEGAL_DATA_FORMAT
self.write_ret(status)
return
try:
tmobile = data.tmobile
user = QueryHelper.get_user_by_tmobile(tmobile, self.db)
if user:
umobile = user.owner_mobile
terminal = QueryHelper.get_terminal_by_tmobile(
tmobile, self.db)
if int(terminal.biz_type) == UWEB.BIZ_TYPE.YDWS:
register_sms = SMSCode.SMS_REGISTER % (umobile, tmobile)
ret = SMSHelper.send_to_terminal(tmobile, register_sms)
else:
activation_code = QueryHelper.get_activation_code(self.db)
register_sms = SMSCode.SMS_REGISTER_YDWQ % (
ConfHelper.UWEB_CONF.url_out, activation_code)
ret = SMSHelper.send(tmobile, register_sms)
ret = DotDict(json_decode(ret))
if ret.status == ErrorCode.SUCCESS:
logging.info("[UWEB] Reregist successfully. umobile: %s, tmobile: %s .",
umobile, tmobile)
else:
status = ErrorCode.REGISTER_FAILED
logging.error("[UWEB] Reregister failed. umobile: %s, tmobile: %s. Message: %s",
umobile, tmobile, ErrorCode.ERROR_MESSAGE[status])
else:
logging.exception("[UWEB] Terminal has no user, ignore it. tmobile: %s. ",
tmobile)
self.write_ret(status)
except Exception as e:
logging.exception("[UWEB] Reregister failed. tmobile: %s , Exception: %s",
tmobile, e.args)
status = ErrorCode.REGISTER_FAILED
self.write_ret(status)