本文整理汇总了Python中mongodb_store.message_store.MessageStoreProxy.query_id方法的典型用法代码示例。如果您正苦于以下问题:Python MessageStoreProxy.query_id方法的具体用法?Python MessageStoreProxy.query_id怎么用?Python MessageStoreProxy.query_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mongodb_store.message_store.MessageStoreProxy
的用法示例。
在下文中一共展示了MessageStoreProxy.query_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_message_store_messages
# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import query_id [as 别名]
def get_message_store_messages(self, typ=None):
msgs = []
proxy = MessageStoreProxy()
for msg in self._msg_store_objects:
if typ != msg.typ and typ is not None:
continue
proxy.database = msg.database
proxy.collection = msg.collection
msgs.append(proxy.query_id(msg.obj_id, msg.typ)[0])
return msgs
示例2: StringPairList
# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import query_id [as 别名]
# now store ids togther in store, addition types for safety
spl = StringPairList()
for pair in stored:
spl.pairs.append(StringPair(pair[0], pair[1]))
# and add some meta information
meta = {}
meta['description'] = "this wasn't great"
meta['result_time'] = datetime.utcfromtimestamp(rospy.get_rostime().to_sec())
msg_store.insert(spl, meta = meta)
# now let's get all our logged data back
results = msg_store.query(StringPairList._type)
for message, meta in results:
if 'description' in meta:
print 'description: %s' % meta['description']
print 'result time (UTC from rostime): %s' % meta['result_time']
print 'inserted at (UTC from rostime): %s' % meta['inserted_at']
pose = msg_store.query_id(message.pairs[0].second, Pose._type)
point = msg_store.query_id(message.pairs[1].second, Point._type)
quaternion = msg_store.query_id(message.pairs[2].second, Quaternion._type)
result = msg_store.query_id(message.pairs[3].second, Bool._type)
except rospy.ServiceException, e:
print "Service call failed: %s"%e
示例3:
# 需要导入模块: from mongodb_store.message_store import MessageStoreProxy [as 别名]
# 或者: from mongodb_store.message_store.MessageStoreProxy import query_id [as 别名]
p_id = msg_store.insert(['test1', 'test2'])
# get it back with a name
print msg_store.query_named("my favourite pose", Pose._type)
p.position.x = 666
# update it with a name
msg_store.update_named("my favourite pose", p)
p.position.y = 2020
# update the other inserted one using the id
msg_store.update_id(p_id, p)
stored_p, meta = msg_store.query_id(p_id, Pose._type)
assert stored_p.position.x == 666
assert stored_p.position.y == 2020
print "stored object ok"
print "stored object inserted at %s (UTC rostime) by %s" % (meta['inserted_at'], meta['inserted_by'])
print "stored object last updated at %s (UTC rostime) by %s" % (meta['last_updated_at'], meta['last_updated_by'])
# some other things you can do...
# get it back with a name
print msg_store.query_named("my favourite pose", Pose._type)
# try to get it back with an incorrect name, so get None instead
print msg_store.query_named("my favourite position", Pose._type)