本文整理汇总了Python中helpers.queryhelper.QueryHelper.get_user_by_uid方法的典型用法代码示例。如果您正苦于以下问题:Python QueryHelper.get_user_by_uid方法的具体用法?Python QueryHelper.get_user_by_uid怎么用?Python QueryHelper.get_user_by_uid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpers.queryhelper.QueryHelper
的用法示例。
在下文中一共展示了QueryHelper.get_user_by_uid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_user_by_uid [as 别名]
def get(self):
"""Display profile of current user.
"""
status = ErrorCode.SUCCESS
try:
tid = self.get_argument('tid',None)
# check tid whether exist in request and update current_user
self.check_tid(tid)
profile = DotDict()
# 1: user
user = QueryHelper.get_user_by_uid(self.current_user.uid, self.db)
if not user:
status = ErrorCode.LOGIN_AGAIN
logging.error("[UWEB] User does not exist, redirect to login.html. uid: %s.",
self.current_user.uid)
self.write_ret(status)
return
# 2: car
car = QueryHelper.get_car_by_tid(self.current_user.tid, self.db)
profile.update(user)
profile.update(car)
self.write_ret(status,
dict_=dict(profile=profile))
except Exception as e:
logging.exception("[UWEB] Get user profile failed. uid:%s, tid:%s, Exception: %s",
self.current_user.uid, self.current_user.tid, e.args)
status = ErrorCode.SERVER_BUSY
self.write_ret(status)
示例2: post
# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_user_by_uid [as 别名]
def post(self):
uid = self.get_argument("uid", "")
message = None
url = None
user = QueryHelper.get_user_by_uid(uid, self.db)
if not user:
message = ErrorCode.USER_NOT_FOUND
self.render("delegation/delegation_individual.html", message=message, url=url)
else:
tid = "dummy"
tmobile = "dummy"
cid = UWEB.DUMMY_CID
oid = UWEB.DUMMY_OID
url = "/".join(
[
ConfHelper.UWEB_CONF.url_out,
UWebHelper.URLS.DELEGATION[1:],
str(uid),
str(tid),
str(tmobile),
str(cid),
str(oid),
]
)
sign = UWebHelper.get_sign("".join([str(uid), str(tid), str(tmobile), str(cid), str(oid)]))
url += "?s=" + sign
self.log_delegation(self.current_user.id, cid, uid, tid)
self.render("delegation/delegation_individual.html", message=message, url=url)
示例3: put
# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_user_by_uid [as 别名]
def put(self):
"""Update the parameters of terminal.
"""
status = ErrorCode.SUCCESS
try:
data = DotDict(json_decode(self.request.body))
tid = data.get('tid', None)
# check tid whether exist in request and update current_user
self.check_tid(tid)
logging.info("[UWEB] Terminal request: %s, uid: %s, tid: %s",
data, self.current_user.uid, self.current_user.tid)
except Exception as e:
status = ErrorCode.ILLEGAL_DATA_FORMAT
self.write_ret(status)
return
try:
terminal = QueryHelper.get_available_terminal(
self.current_user.tid, self.db)
if not terminal:
status = ErrorCode.LOGIN_AGAIN
logging.error("[UWEB] The terminal with tid: %s does not exist,"
" redirect to login.html",
self.current_user.tid)
self.write_ret(status)
return
user = QueryHelper.get_user_by_uid(self.current_user.uid, self.db)
if not user:
status = ErrorCode.LOGIN_AGAIN
logging.error("[UWEB] The user with uid: %s does not exist,"
" redirect to login.html",
self.current_user.uid)
self.write_ret(status)
return
# sql injection
if data.has_key('corp_cnum') and not check_cnum(data.corp_cnum):
status = ErrorCode.ILLEGAL_CNUM
self.write_ret(status)
return
# NOTE: deprecated
if data.has_key('white_list'):
white_list = ":".join(data.white_list)
if not check_sql_injection(white_list):
status = ErrorCode.ILLEGAL_WHITELIST
self.write_ret(status)
return
self.update_terminal_db(data)
# NOTE: wspush to client
if status == ErrorCode.SUCCESS:
WSPushHelper.pushS7(tid, self.db, self.redis)
self.write_ret(status)
except Exception as e:
logging.exception("[UWEB] uid:%s, tid:%s update terminal info failed. Exception: %s",
self.current_user.uid, self.current_user.tid, e.args)
status = ErrorCode.SERVER_BUSY
self.write_ret(status)
示例4: post
# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_user_by_uid [as 别名]
def post(self):
logging.info("[UWEB] Android login test")
status = ErrorCode.SUCCESS
cid = UWEB.DUMMY_CID
oid = UWEB.DUMMY_OID
uid = ConfHelper.UWEB_CONF.test_uid
tid = ConfHelper.UWEB_CONF.test_tid
sim = ConfHelper.UWEB_CONF.test_sim
version_type = int(self.get_argument("version_type", 0))
biz_type = UWEB.BIZ_TYPE.YDWS
self.bookkeep(dict(cid=cid,
oid=oid,
uid=uid,
tid=tid,
sim=sim))
user_info = QueryHelper.get_user_by_uid(uid, self.db)
# NOTE: add cars_info, it's same as lastinfo
cars_info = {}
terminals = QueryHelper.get_terminals_by_uid(uid, biz_type, self.db)
for terminal in terminals:
# 1: get terminal
tid = terminal.tid
group_info = get_group_info_by_tid(self.db, tid)
terminal_info_key = get_terminal_info_key(tid)
terminal_cache = self.redis.getvalue(terminal_info_key)
if terminal_cache:
terminal['gps'] = terminal_cache['gps']
terminal['gsm'] = terminal_cache['gsm']
terminal['pbat'] = terminal_cache['pbat']
mobile = terminal['mobile']
terminal['keys_num'] = 0
if terminal['login'] == GATEWAY.TERMINAL_LOGIN.SLEEP:
terminal['login'] = GATEWAY.TERMINAL_LOGIN.ONLINE
# NOTE: if alias is null, provide cnum or sim instead
terminal['alias'] = QueryHelper.get_alias_by_tid(
tid, self.redis, self.db)
fobs = self.db.query("SELECT fobid FROM T_FOB"
" WHERE tid = %s", tid)
terminal['fob_list'] = [fob.fobid for fob in fobs]
terminal['sim'] = terminal['mobile']
# 2: get location
location = QueryHelper.get_location_info(tid, self.db, self.redis)
if location and not (location.clatitude or location.clongitude):
location_key = get_location_key(str(tid))
locations = [location, ]
locations = get_locations_with_clatlon(locations, self.db)
location = locations[0]
self.redis.setvalue(
location_key, location, EVENTER.LOCATION_EXPIRY)
if location and location['name'] is None:
location['name'] = ''
avatar_name, avatar_path, avatar_full_path, avatar_time = self.get_avatar_info(
mobile)
service_status = QueryHelper.get_service_status_by_tmobile(
self.db, mobile)
car_dct = {}
if location and location['type'] == 1: # cellid
location['locate_error'] = 500 # mile
car_info = dict(defend_status=terminal['defend_status'] if terminal['defend_status'] is not None else 1,
service_status=service_status,
mannual_status=terminal['mannual_status'] if terminal['mannual_status'] is not None else 1,
fob_status=terminal['fob_status'] if terminal['fob_status'] is not None else 0,
timestamp=location['timestamp'] if location else 0,
speed=location.speed if location else 0,
# NOTE: degree's type is Decimal, float() it before json_encode
degree=float(location.degree) if location else 0.00,
locate_error=location.get('locate_error', 20) if location else 20,
bt_name=terminal['bt_name'] if terminal.get('bt_name', None) is not None else '',
bt_mac=terminal['bt_mac'] if terminal.get('bt_mac', None) is not None else '',
dev_type=terminal['dev_type'] if terminal.get('dev_type', None) is not None else 'A',
name=location.name if location else '',
type=location.type if location else 1,
latitude=location['latitude'] if location else 0,
longitude=location['longitude'] if location else 0,
clatitude=location['clatitude'] if location else 0,
clongitude=location['clongitude'] if location else 0,
login=terminal['login'] if terminal['login'] is not None else 0,
gps=terminal['gps'] if terminal['gps'] is not None else 0,
gsm=terminal['gsm'] if terminal['gsm'] is not None else 0,
pbat=terminal['pbat'] if terminal['pbat'] is not None else 0,
mobile=terminal['mobile'],
owner_mobile=terminal['owner_mobile'],
alias=terminal['alias'],
#keys_num=terminal['keys_num'] if terminal['keys_num'] is not None else 0,
keys_num=0,
group_id=group_info['group_id'],
group_name=group_info['group_name'],
icon_type=terminal['icon_type'],
avatar_path=avatar_path,
#.........这里部分代码省略.........
示例5: get
# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_user_by_uid [as 别名]
def get(self):
"""Get terminal info.
"""
status = ErrorCode.SUCCESS
try:
tid = self.get_argument('tid', None)
# check tid whether exist in request and update current_user
self.check_tid(tid)
# part 1: terminal
tracker = DotDict()
# 1: terminal
# NOTE: static_val, move_val are deprecated
terminal = QueryHelper.get_available_terminal(
self.current_user.tid, self.db)
if not terminal:
status = ErrorCode.LOGIN_AGAIN
logging.error("The terminal with tid: %s does not exist, redirect to login.html",
self.current_user.tid)
self.write_ret(status)
return
# 撤防,智能设防
if terminal['mannual_status'] != UWEB.DEFEND_STATUS.YES:
terminal['parking_defend'] = 1
else: # 强力设防
terminal['parking_defend'] = 0
# 2: sos is deprecatd
user = QueryHelper.get_user_by_uid(self.current_user.uid, self.db)
if not user:
status = ErrorCode.LOGIN_AGAIN
logging.error("The user with uid: %s does not exist, redirect to login.html",
self.current_user.uid)
self.write_ret(status)
return
sos = dict(mobile='')
tracker.update(sos)
tracker.update(dict(push_status=terminal.push_status))
tracker.update(dict(sos_pop=terminal.white_pop))
tracker.update(dict(vibl=terminal.vibl))
tracker.update(dict(static_val=terminal.static_val))
tracker.update(dict(parking_defend=terminal.parking_defend))
tracker.update(dict(owner_mobile=terminal.owner_mobile))
tracker.update(dict(speed_limit=terminal.speed_limit))
# part 2: profile
profile = DotDict()
car = QueryHelper.get_car_by_tid(self.current_user.tid, self.db)
profile.update(dict(name=user.name,
mobile=user.mobile,
email=user.email,
cnum=car.cnum))
# part 3: sms option
sms_options = QueryHelper.get_sms_option(user.mobile, self.db)
# part 5: corp info
corp = DotDict()
corp = QueryHelper.get_corp_by_cid(self.current_user.cid, self.db)
self.write_ret(status,
dict_=dict(tracker=tracker,
sms_options=sms_options,
profile=profile,
corp=corp))
except Exception as e:
status = ErrorCode.SERVER_BUSY
logging.exception("[UWEB] Get appsetting failed. uid: %s tid: %s, Exception: %s",
self.current_user.uid, self.current_user.tid, e.args)
self.write_ret(status)
示例6: get
# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_user_by_uid [as 别名]
def get(self):
status=ErrorCode.SUCCESS
# from_ = self.get_argument('from', '').lower()
index_html = "index.html"
bizcode = None
name = ''
if self.current_user.oid != UWEB.DUMMY_OID: # operator
index_html = "index_corp.html"
umobile=self.current_user.oid
user_info = QueryHelper.get_operator_by_oid(self.current_user.oid, self.db)
corp_info = QueryHelper.get_corp_by_oid(self.current_user.oid, self.db)
if user_info:
name = user_info.name if user_info.name else user_info.mobile
user_type = UWEB.USER_TYPE.OPERATOR
bizcode = corp_info.bizcode
elif self.current_user.cid != UWEB.DUMMY_CID: # corp
index_html = "index_corp.html"
umobile=self.current_user.cid
user_info = QueryHelper.get_corp_by_cid(self.current_user.cid, self.db)
if user_info:
name = user_info.c_linkman if user_info.c_linkman else user_info.c_mobile
user_type = UWEB.USER_TYPE.CORP
bizcode = user_info.bizcode
else: # user
umobile=self.current_user.uid
user_info = QueryHelper.get_user_by_uid(self.current_user.uid, self.db)
if user_info:
name = user_info.name if user_info.name else user_info.mobile
user_type = UWEB.USER_TYPE.PERSON
if not user_info:
status = ErrorCode.LOGIN_AGAIN
logging.error("The user with uid: %s does not exist, redirect to login.html", self.current_user.uid)
self.render("login.html",
username='',
password='',
user_type=UWEB.USER_TYPE.PERSON,
message=None,
message_captcha=None)
return
static_hash = self.redis.get('static_hash')
static_hash = static_hash if static_hash else u'dummy_hash'
wspush = dict(id='',
key='')
json_data = WSPushHelper.register_wspush(umobile, self.redis)
if json_data:
data = json_data['data']
id = data.get('push_id', '')
key = data.get('psd', '')
wspush['id'] = id
wspush['key'] = key
self.render(index_html,
map_type=ConfHelper.LBMP_CONF.map_type,
user_type=user_type,
bizcode=bizcode,
status=status,
name=name,
umobile=umobile,
static_hash=static_hash,
wspush=wspush,)