本文整理汇总了Python中utils.dotdict.DotDict类的典型用法代码示例。如果您正苦于以下问题:Python DotDict类的具体用法?Python DotDict怎么用?Python DotDict使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DotDict类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: post
def post(self):
"""Turn on buletooth."""
status = ErrorCode.SUCCESS
try:
data = DotDict(json_decode(self.request.body))
tid = data.get('tid', None)
tids = data.get('tids', None)
self.check_tid(tid)
logging.info("[BLUETOOTH] kqly request: %s, uid: %s, tids: %s",
data, self.current_user.uid, tids)
except Exception as e:
status = ErrorCode.ILLEGAL_DATA_FORMAT
logging.exception("[UWEB] Invalid data format. body:%s, Exception: %s",
self.request.body, e.args)
self.write_ret(status)
return
try:
tids = str_to_list(tids)
tids = tids if tids else [self.current_user.tid, ]
tids = [str(t) for t in tids]
kqly(self.db, self.redis, tids)
self.write_ret(status)
except Exception as e:
logging.exception("[BLUETOOTH] Kqly 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)
开发者ID:jcsy521,项目名称:ydws,代码行数:28,代码来源:bluetooth.py
示例2: get_tinyurl
def get_tinyurl(url):
"""Get a tiny url for wap url.
"""
try:
# Baidu dwz
#h = httplib2.Http()
#msg={'url':url}
#url_create = 'http://dwz.cn/create.php'
#response, content = h.request(url_create, "POST", urlencode(msg), headers={'Content-Type': 'application/x-www-form-urlencoded'})
#res = DotDict(json_decode(content))
#logging.info("[TINY_URL] response: %s", res)
#if res.status == 0:
# return res.tinyurl
#else:
# return None
# google
h = httplib2.Http()
url_create = 'https://www.googleapis.com/urlshortener/v1/url'
msg = json_encode({'longUrl': url})
response, content = h.request(url_create,
"POST",
msg,
headers = {'Content-Type': 'application/json'})
res = DotDict(json_decode(content))
logging.info("[TINY_URL] response: %s", res)
return res.get('id', None)
except Exception as e:
logging.exception("Get tiny url failed. Exception: %s", e.args)
return None
开发者ID:jcsy521,项目名称:ydws,代码行数:31,代码来源:urlhelper.py
示例3: post
def post(self):
"""Clear the cookie and set defend."""
try:
data = DotDict(json_decode(self.request.body))
devid = data.get("devid", "")
logging.info("[UWEB] logout request: %s, uid: %s",
data, self.current_user.uid)
except:
self.write_ret(ErrorCode.ILLEGAL_DATA_FORMAT)
logging.error("[UWEB] illegal format, body:%s", self.request.body)
else:
# 1: if there are tids, set defend
for tid in data.tids:
update_mannual_status(self.db, self.redis, tid, UWEB.DEFEND_STATUS.YES)
# 2: remove devid from android_push_list
android_push_list_key = get_android_push_list_key(
self.current_user.uid)
android_push_list = self.redis.getvalue(android_push_list_key)
android_push_list = android_push_list if android_push_list else []
if devid in android_push_list:
android_push_list.remove(devid)
self.redis.set(android_push_list_key, android_push_list)
logging.info("[UWEB] uid:%s, android_push_lst: %s",
self.current_user.uid, android_push_list)
finally:
# 3: clear cookie
self.clear_cookie(self.app_name)
self.write_ret(ErrorCode.SUCCESS)
开发者ID:jcsy521,项目名称:ydws,代码行数:29,代码来源:login.py
示例4: retrieve
def retrieve(self, citylist=None):
"""core for Retrieving and Storing operation."""
#store the complete data of curent month into MongoDB
if not citylist:
cities = self.mysql_db.query("SELECT DISTINCT region_code AS id"
" FROM T_HLR_CITY")
citylist = [c.id for c in cities]
results = self.retrieve_mixin(citylist)
# get the group_id list from mongodb(may include the group_id has been removed)
res = self.collection.find({'city_id': { '$in' : citylist }}, {'group_id':1})
ids_mongod = [int(v['group_id']) for v in res]
# get the group_id lsit from mysql (the latest)
ids_mysql = [int(result['group_id']) for result in results]
# get the group_id to be removed and remove them from mongodb
ids_move = list(set(ids_mongod) - set(ids_mysql))
self.collection.remove({'group_id': {'$in':ids_move}})
try:
for result in results:
result = DotDict(result)
oldresult = self.collection.find_one({'id': result.id})
if oldresult:
result['_id'] = oldresult['_id']
else:
result.pop('_id')
self.collection.save(result)
except:
logging.exception('mongodb connected failed')
return results
开发者ID:jcsy521,项目名称:ydws,代码行数:31,代码来源:mgroup.py
示例5: post
def post(self):
status = WXErrorCode.SUCCESS
try:
data = DotDict(json_decode(self.request.body))
tid = data.get('tid', None)
mannual_status = data.get('mannual_status', None)
terminal = self.db.get("SELECT mannual_status, defend_status, service_status FROM T_TERMINAL_INFO "
"WHERE tid = %s ", tid)
if terminal:
service_status = terminal['service_status']
if int(service_status) == 0:
status = WXErrorCode.OUTSERVICE
self.write_ret(status=status,
message=WXErrorCode.ERROR_MESSAGE[status])
return
try:
self.db.execute("UPDATE T_TERMINAL_INFO SET mannual_status = %s"
"WHERE tid = %s", mannual_status, tid)
except MySQLdb.Error as e:
logging.exception("[WEIXIN] execute update sql terminal:%s mannual_stauts failed ",
tid, e.args)
status = WXErrorCode.SERVER_BUSY
self.write_ret(status=status,
message=WXErrorCode.ERROR_MESSAGE[status])
except Exception as e:
logging.exception("[WEIXIN] update terminal:%s mannual_stauts failed", tid)
status = WXErrorCode.FAILED
self.write_ret(status=status,
message=WXErrorCode.ERROR_MESSAGE[status])
开发者ID:jcsy521,项目名称:ydws,代码行数:34,代码来源:defend.py
示例6: handle_request
def handle_request(self, data):
try:
packet = T_CLWCheck(data)
command = packet.head.command
if command == GATEWAY.T_MESSAGE_TYPE.AGPS:
head = packet.head
body = packet.body
args = DotDict(success=GATEWAY.RESPONSE_STATUS.SUCCESS,
agps_data=None)
ap = AgpsParser(body, head)
agps_sign = self.get_agps_sign(ap.ret, int(head.timestamp))
if agps_sign != int(head.agps_sign, 16):
args.success = GATEWAY.RESPONSE_STATUS.INVALID_SESSIONID
logging.error("[AGPS] agps_sign invalid.")
else:
agps = ap.ret
args.agps_data = self.get_agps_from_redis(agps)
if args.agps_data:
ac = AgpsComposer(args)
return ac.buf
else:
logging.error("[AGPS] there's no invalid agps data.")
return None
except:
logging.exception("[AGPS] Handle agps request exception.")
return None
开发者ID:jcsy521,项目名称:ydws,代码行数:26,代码来源:server.py
示例7: put
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)
开发者ID:jcsy521,项目名称:ydws,代码行数:60,代码来源:terminal.py
示例8: get
def get(self):
"""Display profile of current operator.
"""
status = ErrorCode.SUCCESS
try:
profile = DotDict()
# 1: user
oper = QueryHelper.get_operator_by_oid(self.current_user.oid, self.db)
if not oper:
status = ErrorCode.LOGIN_AGAIN
logging.error("[UWEB] Operator does not exist, redirect to login.html. oid: %s.",
self.current_user.oid)
self.write_ret(status)
return
profile.update(oper)
for key in profile.keys():
profile[key] = profile[key] if profile[key] else ''
self.write_ret(status,
dict_=dict(profile=profile))
except Exception as e:
logging.exception("[UWEB] Get corp profile failed. oid:%s, tid:%s, Exception: %s",
self.current_user.oid, self.current_user.tid, e.args)
status = ErrorCode.SERVER_BUSY
self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:25,代码来源:profile.py
示例9: post
def post(self):
status = ErrorCode.SUCCESS
try:
data = DotDict(json_decode(self.request.body))
tid = data.get("tid", None)
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(status)
return
try:
tid = data["tid"]
items = self.db.query("SELECT * FROM T_ALERT_SETTING WHERE tid=%s", tid)
if len(items) >= 7:
status = ErrorCode.FAILED
self.write_ret(status)
logging.error("[UWEB] terminal %s set too many event periods", tid)
else:
start_time = data["start_time"]
end_time = data["end_time"]
week = data["week"]
self.db.execute("INSERT INTO T_ALERT_SETTING"
" VALUES(NULL, %s, %s, %s, %s)",
tid, start_time, end_time, week)
logging.info("[UWEB] terminal add event period success: %s", data)
self.write_ret(status)
except Exception as e:
logging.exception("[UWEB] tid:%s insert event period. Exception:%s",
tid, e.args)
status = ErrorCode.FAILED
self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:34,代码来源:eventperiod.py
示例10: put
def put(self):
"""Modify profile of current operator.
"""
status = ErrorCode.SUCCESS
try:
data = DotDict(json_decode(self.request.body))
logging.info("[UWEB] Operator profile request: %s, oid: %s, tid: %s",
data, self.current_user.oid, self.current_user.tid)
except Exception as e:
status = ErrorCode.ILLEGAL_DATA_FORMAT
self.write_ret(status)
return
try:
#if data.has_key('email') and not check_sql_injection(data.email):
if data.has_key('email') and len(data.email)>50:
status = ErrorCode.ILLEGAL_EMAIL
self.write_ret(status,
message=u'联系人邮箱的最大长度是50个字符!')
return
update_operator(data, self.current_user.oid, self.db, self.redis)
self.write_ret(status)
except Exception as e:
logging.exception("[UWEB] Update operator profile failed. oid:%s, Exception: %s",
self.current_user.oid, e.args)
status = ErrorCode.SERVER_BUSY
self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:28,代码来源:profile.py
示例11: handle_fob_info
def handle_fob_info(info, address, connection, channel, exchange, gw_binding, db, redis):
"""
S19
NOTE: deprecated
fob info packet: add or remove fob
0: success, then record new terminal's address
1: invalid SessionID
"""
try:
head = info.head
body = info.body
dev_id = head.dev_id
args = DotDict(success=GATEWAY.RESPONSE_STATUS.SUCCESS)
sessionID = QueryHelper.get_terminal_sessionID(dev_id, redis)
if sessionID != head.sessionID:
args.success = GATEWAY.RESPONSE_STATUS.INVALID_SESSIONID
else:
fp = FobInfoParser(body, head)
fobinfo = fp.ret
update_terminal_status(redis, head.dev_id, address)
update_fob_info(db, redis, fobinfo)
fc = FobInfoRespComposer(args)
request = DotDict(packet=fc.buf,
address=address,
dev_id=dev_id)
append_gw_request(request, connection, channel, exchange, gw_binding)
except:
logging.exception("[GW] Handle fob info report exception.")
GWException().notify()
开发者ID:jcsy521,项目名称:ydws,代码行数:31,代码来源:fob.py
示例12: retrieve
def retrieve(self, city_list=None, end_time=None):
"""core for Retrieving and Storing operation."""
"""This method returns the last day"""
if not end_time:
d = datetime.datetime.fromtimestamp(time.time())
t = datetime.datetime.combine(datetime.date(d.year, d.month, d.day), datetime.time(0, 0))
# get today 0:00:00
end_time = int(time.mktime(t.timetuple())*1000)
if not city_list:
cities = self.mysql_db.query("SELECT DISTINCT region_code AS id FROM T_HLR_CITY")
city_list = [city.id for city in cities]
results = self.retrieve_mixin(city_list, end_time)
try:
for result in results:
result = DotDict(result)
query_term = {'city_id': result.city_id, 'timestamp': result.timestamp}
oldresult = self.collection.find_one(query_term)
if oldresult:
result['_id'] = oldresult['_id']
else:
result.pop('_id')
self.collection.save(result)
except Exception as e:
logging.exception('mongodb saved failed. Error: %s', e.args)
return results
开发者ID:jcsy521,项目名称:ydws,代码行数:28,代码来源:mdaily.py
示例13: update_operator
def update_operator(operator, oid, db, redis):
"""Update operator status.
:arg operator: dict, e.g.
{
'address':'',
'email':'',
}
:arg oid: string
:arg db: database instance
:arg redis: redis instance
"""
set_clause_dct = DotDict()
fields = DotDict(address="address = '%s'",
email="email = '%s'")
for key, value in operator.iteritems():
set_clause_dct.setdefault(key, fields[key] % value)
set_clause = ','.join(
[v for v in set_clause_dct.itervalues() if v is not None])
if set_clause:
db.execute("UPDATE T_OPERATOR SET " + set_clause +
" WHERE oid = %s",
oid)
开发者ID:jcsy521,项目名称:ydws,代码行数:27,代码来源:public.py
示例14: post
def post(self, ecmobile):
"""Modify a business.
"""
fields = DotDict(ecname=" name = '%s'",
ecmobile=" mobile = '%s'",
linkman="linkman = '%s'",
address="address = '%s'",
email="email = '%s'",
bizcode="bizcode = '%s'",
type="type = '%s'")
for key in fields:
v = self.get_argument(key, None)
if v is not None:
# if not check_sql_injection(v):
# call get method
# self.get(tmobile)
# return
fields[key] = fields[key] % v
else:
fields[key] = None
set_cmd = ', '.join([v for v in fields.itervalues()
if v is not None])
sql = "UPDATE T_CORP SET " + set_cmd + " WHERE mobile = %s" % ecmobile
self.db.execute(sql)
self.redirect("/ecbusiness/list/%s" % ecmobile)
开发者ID:jcsy521,项目名称:ydws,代码行数:28,代码来源:ecbusiness.py
示例15: post
def post(self):
"""Insert new items."""
status = ErrorCode.SUCCESS
try:
data = DotDict(json_decode(self.request.body))
content = data.get('content', '')
mobiles = data.get('mobiles', None)
logging.info("[UWEB] Announcement request: %s", data)
except Exception as e:
status = ErrorCode.ILLEGAL_DATA_FORMAT
self.write_ret(status)
return
try:
mobiles_ = u''
if mobiles is not None:
mobiles_ = ','.join(mobiles)
for mobile in mobiles:
SMSHelper.send(mobile, content)
announcement = dict(cid=self.current_user.cid,
content=content,
mobiles=mobiles_)
record_announcement(self.db, announcement)
self.write_ret(status)
except Exception as e:
status = ErrorCode.SERVER_BUSY
logging.exception(
"[UWEB] record share failed, Exception: %s", e.args)
self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:31,代码来源:announcement.py
示例16: get_realtime
def get_realtime(self, uid, sim):
"""Get the location of the current realtime request.
workflow:
if there is alive memcached, we can get location from it,
else get location from db
return result to user browser
"""
ret = DotDict(status=ErrorCode.SUCCESS,
message='',
location=None)
location = QueryHelper.get_location_info(self.current_user.tid, self.db, self.redis)
locations = [location,]
locations = get_locations_with_clatlon(locations, self.db)
location = locations[0]
if (location and location.clatitude and location.clongitude):
if not location.name:
location.name = ''
if location.has_key('id'):
del location['id']
location['degree'] = float(location.degree)
location['tid'] = self.current_user.tid
ret.location = location
return ret
开发者ID:jcsy521,项目名称:ydws,代码行数:28,代码来源:realtime.py
示例17: handle_acc_status_report
def handle_acc_status_report(info, address, connection, channel, exchange, gw_binding, db, redis):
"""
S31
ACC_status_report:
0: success, then record new terminal's address
1: invalid SessionID
"""
try:
head = info.head
body = info.body
dev_id = head.dev_id
args = DotDict(success=GATEWAY.RESPONSE_STATUS.SUCCESS,
command=head.command)
sessionID = QueryHelper.get_terminal_sessionID(dev_id, redis)
if sessionID != head.sessionID:
args.success = GATEWAY.RESPONSE_STATUS.INVALID_SESSIONID
logging.error("[GW] Invalid sessionID, terminal: %s", head.dev_id)
else:
uap = ACCStatusReportParser(body, head)
t_info = uap.ret
#NOTE: Just record it in db.
db.execute("INSERT INTO T_ACC_STATUS_REPORT(tid, category, timestamp)"
" VALUES(%s, %s, %s)",
t_info['dev_id'], t_info['category'], t_info['timestamp'])
asc = ACCStatusReportComposer(args)
request = DotDict(packet=asc.buf,
address=address,
dev_id=dev_id)
append_gw_request(request, connection, channel, exchange, gw_binding)
except:
logging.exception("[GW] Handle acc status report exception.")
GWException().notify()
开发者ID:jcsy521,项目名称:ydws,代码行数:34,代码来源:acc.py
示例18: get
def get(self):
""" """
status = ErrorCode.SUCCESS
try:
page_number = int(self.get_argument('pagenum'))
page_count = int(self.get_argument('pagecnt'))
#reserved API
fields = DotDict(name="name LIKE '%%%%%s%%%%'")
for key in fields.iterkeys():
v = self.get_argument(key, None)
if v:
if not check_sql_injection(v):
status = ErrorCode.SELECT_CONDITION_ILLEGAL
self.write_ret(status)
return
fields[key] = fields[key] % (v,)
else:
fields[key] = None
except Exception as e:
status = ErrorCode.ILLEGAL_DATA_FORMAT
logging.exception("[UWEB] cid: %s get line data format illegal. Exception: %s",
self.current_user.cid, e.args)
self.write_ret(status)
return
try:
where_clause = ' AND '.join([v for v in fields.itervalues()
if v is not None])
page_size = UWEB.LIMIT.PAGE_SIZE
if where_clause:
where_clause = ' AND ' + where_clause
if page_count == -1:
sql = "SELECT count(id) as count FROM T_LINE" + \
" WHERE 1=1 " + where_clause
sql += " AND cid = %s" % (self.current_user.cid,)
res = self.db.get(sql)
count = res.count
d, m = divmod(count, page_size)
page_count = (d + 1) if m else d
sql = "SELECT id AS line_id, name AS line_name FROM T_LINE" +\
" WHERE 1=1 " + where_clause
sql += " AND cid = %s LIMIT %s, %s" % (self.current_user.cid, page_number * page_size, page_size)
lines = self.db.query(sql)
for line in lines:
stations = self.db.query("SELECT name, latitude, longitude, seq "
" FROM T_STATION "
" WHERE line_id = %s",
line.line_id)
line["stations"] = stations
self.write_ret(status,
dict_=DotDict(lines=lines,
pagecnt=page_count))
except Exception as e:
logging.exception("[UWEB] cid: %s get line failed. Exception: %s",
self.current_user.cid, e.args)
status = ErrorCode.SERVER_BUSY
self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:60,代码来源:line.py
示例19: handle_sleep
def handle_sleep(info, address, connection, channel, exchange, gw_binding, db, redis):
"""
S21
sleep status packet: 0-sleep, 1-LQ
0: success, then record new terminal's address
1: invalid SessionID
"""
try:
head = info.head
body = info.body
dev_id = head.dev_id
resend_key, resend_flag = get_resend_flag(redis, dev_id, head.timestamp, head.command)
args = DotDict(success=GATEWAY.RESPONSE_STATUS.SUCCESS,
command=head.command)
sessionID = QueryHelper.get_terminal_sessionID(dev_id, redis)
is_sleep = False
if sessionID != head.sessionID:
args.success = GATEWAY.RESPONSE_STATUS.INVALID_SESSIONID
else:
if resend_flag:
logging.warn("[GW] Recv resend packet, head: %s, body: %s and drop it!",
info.head, info.body)
else:
redis.setvalue(resend_key, True, GATEWAY.RESEND_EXPIRY)
hp = AsyncParser(body, head)
sleep_info = hp.ret
if sleep_info['sleep_status'] == '0':
sleep_info['login'] = GATEWAY.TERMINAL_LOGIN.SLEEP
#self.send_lq_sms(head.dev_id)
#logging.info("[GW] Recv sleep packet, LQ it: %s", head.dev_id)
is_sleep = True
elif sleep_info['sleep_status'] == '1':
sleep_info['login'] = GATEWAY.TERMINAL_LOGIN.ONLINE
else:
logging.info("[GW] Recv wrong sleep status: %s", sleep_info)
del sleep_info['sleep_status']
update_terminal_info(db, redis, sleep_info)
update_terminal_status(redis, dev_id, address, is_sleep)
if args['success'] == GATEWAY.RESPONSE_STATUS.SUCCESS:
acc_status_info_key = get_acc_status_info_key(dev_id)
acc_status_info = redis.getvalue(acc_status_info_key)
if acc_status_info and (not acc_status_info['t2_status']): # T2(query) is need
args['success'] = 3 # acc_status is changed
logging.info("[GW] ACC_status is changed, dev_id: %s, acc_status_info: %s",
dev_id, acc_status_info)
hc = AsyncRespComposer(args)
request = DotDict(packet=hc.buf,
address=address,
dev_id=dev_id)
append_gw_request(request, connection, channel, exchange, gw_binding)
except:
logging.exception("[GW] Handle sleep status report exception.")
GWException().notify()
开发者ID:jcsy521,项目名称:ydws,代码行数:58,代码来源:sleep.py
示例20: insert_location
def insert_location(location, db, redis):
"""Insert whole-data into T_LOCATION.
"""
location = DotDict(location)
# NOTE: if locate_error is bigger then 500, set it 500
if int(location.locate_error) > 500:
location.locate_error = 500
lid = db.execute("INSERT INTO T_LOCATION(tid, latitude, longitude, altitude,"
" clatitude, clongitude, timestamp, name, category, type,"
" speed, degree, cellid, locate_error)"
" VALUES (%s, %s, %s, %s, %s, %s, %s,"
" %s, %s, %s, %s, %s, %s, %s)",
location.dev_id, location.lat, location.lon,
location.alt, location.cLat, location.cLon,
location.gps_time, location.name,
location.category, location.type,
location.speed, location.degree,
location.cellid, location.locate_error)
if location.lat and location.lon:
track_key = get_track_key(location.dev_id)
track = redis.get(track_key)
# if track is on, just put PVT into redis
# maybe put cellid into redis later.
# if track and (int(track) == 1) and (location.get("Tid", None) != EVENTER.TRIGGERID.PVT):
# return lid
# NOTE: if location's type is gps, put it into redis
if track and (int(track) == 1) and (location.type != 0):
return lid
location_key = get_location_key(location.dev_id)
last_location = redis.getvalue(location_key)
if (last_location and (location.gps_time > last_location['timestamp'])) or\
not last_location:
logging.info("[PUBLIC] Keep location in redis. tid: %s, location: %s",
location.dev_id, location)
mem_location = {'id': lid,
'latitude': location.lat,
'longitude': location.lon,
'type': location.type,
'clatitude': location.cLat,
'clongitude': location.cLon,
'timestamp': location.gps_time,
'name': location.name,
'degree': location.degree,
'speed': location.speed,
'locate_error': location.locate_error}
location_key = get_location_key(location.dev_id)
redis.setvalue(location_key, mem_location, EVENTER.LOCATION_EXPIRY)
if int(location.type) == 0: # gps
logging.info("[PUBLIC] Keep gps_location in gps_redis. tid: %s, location: %s",
location.dev_id, location)
location_key = get_gps_location_key(location.dev_id)
redis.setvalue(
location_key, mem_location, EVENTER.LOCATION_EXPIRY)
return lid
开发者ID:jcsy521,项目名称:ydws,代码行数:58,代码来源:public.py
注:本文中的utils.dotdict.DotDict类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论