本文整理汇总了Python中utils.dotdict.DotDict.message方法的典型用法代码示例。如果您正苦于以下问题:Python DotDict.message方法的具体用法?Python DotDict.message怎么用?Python DotDict.message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.dotdict.DotDict
的用法示例。
在下文中一共展示了DotDict.message方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write_ret
# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import message [as 别名]
def write_ret(self, status, message=None, dict_=None):
"""
write back ret message: dict(status=status,
message=ErrorCode.ERROR_MESSAGE[status],
...)
"""
ret = DotDict(status=status)
if message is None:
ret.message = WXErrorCode.ERROR_MESSAGE[status]
else:
ret.message = message
if isinstance(dict_, dict):
ret.update(dict_)
self.set_header(*self.JSON_HEADER)
self.write(json_encode(ret))
示例2: write_ret
# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import message [as 别名]
def write_ret(self, status, message=None, dict_=None):
"""
write back ret message: dict(status=status,
message=ErrorCode.ERROR_MESSAGE[status],
...)
"""
ret = DotDict(status=status)
if message is None:
ret.message = ErrorCode.ERROR_MESSAGE[status]
else:
ret.message = message
try:
ret['message'] = ret['message'].encode('utf8')
except:
pass
if isinstance(dict_, dict):
ret.update(dict_)
self.set_header(*self.JSON_HEADER)
t = json_encode(ret)
self.write(t)
示例3: get
# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import message [as 别名]
def get(self, name):
"""
"""
ret = DotDict(status=ErrorCode.SUCCESS,
message=None)
corp = self.db.get("SELECT id"
" FROM T_CORP"
" WHERE name = %s"
" LIMIT 1",
name)
if corp:
ret.status = ErrorCode.EC_NAME_EXISTED
ret.message = ErrorCode.ERROR_MESSAGE[ret.status]
self.set_header(*self.JSON_HEADER)
self.write(json_encode(ret))
示例4: put
# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import message [as 别名]
def put(self):
"""Modify the remark of the offline-terminal.
"""
ret = DotDict(status=ErrorCode.SUCCESS,
message=None)
try:
data = DotDict(json_decode(self.request.body))
id = data.id
remark = data.remark
self.db.execute("UPDATE T_TERMINAL_INFO"
" SET remark = %s"
" WHERE id = %s",
remark, id)
except Exception as e:
ret.status = ErrorCode.FAILED
ret.message = ErrorCode.ERROR_MESSAGE[ret.status]
logging.exception("[UWEB] Modify remark failed. body: %s, Exception: %s",
self.request.body, e.args)
self.set_header(*self.JSON_HEADER)
self.write(json_encode(ret))
示例5: request_realtime
# 需要导入模块: from utils.dotdict import DotDict [as 别名]
# 或者: from utils.dotdict.DotDict import message [as 别名]
def request_realtime(self, query, callback=None):
"""
All realtime requests in REALTIME_VALID_INTERVAL will be considered as
only one. If not, invoke gf and use handle_location of lbmphelper.
"""
location = QueryHelper.get_location_info(self.current_user.tid, self.db, self.redis)
if location and location['name'] is None:
location['name'] = ''
ret = DotDict(status=ErrorCode.SUCCESS,
message='',
location=None)
locations = [location,]
locations = get_locations_with_clatlon(locations, self.db)
location = locations[0]
if (location and location.clatitude and location.clongitude):
if location.has_key('id'):
del location['id']
location['degree'] = float(location.degree)
location['tid'] = self.current_user.tid
ret.location = location
if callback:
callback(ret)
return
lat, lon = get_latlon_from_cellid(0,0,0,0, self.current_user.sim)
clat, clon = get_clocation_from_ge([lat,],[lon,])
clat = int(clat[0]) if len(clat)>0 else 0
clon = int(clon[0]) if len(clon)>0 else 0
name = get_location_name(clat, clon, self.redis)
location = DotDict(category = 1, # cellid
dev_id = self.current_user.tid,
lat = lat,
lon = lon,
cLat = clat,
cLon = clon,
alt = 0,
gps_time = int(time.time()),
type = 1,
speed = 0.0,
degree = 0.0,
name = name,
cellid = None,
locate_error = 20)
if clat and clon:
ret.location = DotDict()
ret.location.latitude = lat
ret.location.longitude = lon
ret.location.clongitude = clon
ret.location.clatitude = clat
ret.location.timestamp = int(time.time())
ret.location.name = name
ret.location.speed = 0
ret.location.type = 1
ret.location.tid = self.current_user.tid
ret.location.degree = 0.0
ret.location.locte_error = 20
insert_location(location, self.db, self.redis)
logging.info("[UWEB] tid %s cellid query success", self.current_user.tid)
else:
ret.status = ErrorCode.LOCATION_CELLID_FAILED
ret.message = ErrorCode.ERROR_MESSAGE[ret.status]
logging.info("[UWEB] Do not find any location, and cellid query failed. tid: %s",
self.current_user.tid)
if callback:
callback(ret)