本文整理汇总了Python中Engine.createResource方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.createResource方法的具体用法?Python Engine.createResource怎么用?Python Engine.createResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine
的用法示例。
在下文中一共展示了Engine.createResource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: import Engine [as 别名]
# 或者: from Engine import createResource [as 别名]
# Configure our user ID and user Key
e.setUserId(newUserId)
e.setKey(key)
print "User ID:",newUserId," key: ",key
## Create a resource
# Generate random label name
resourceLabel = "demo"+str(random.randint(0,99))
# Create the new Resource's minimal JSON representation
newresource = {"label": resourceLabel}
jsonstr = json.dumps(newresource)
print "Resource JSON: "+jsonstr
# Create the new resource with the Engine
resourceId = e.createResource(jsonstr)
print "Made resource ID: "+str(resourceId);
# Use auto creation of streams and parsers
autoCreateStreams=True
if autoCreateStreams:
# generate a random stream name
tempname = "temperature"+str(random.randint(0,20))
# generate 10 random data points
for x in range(0,10):
# craft a JSON payload
data = { tempname : random.randint(0,20) }
datastr = json.dumps(data)
print "Sending....",datastr
# Post this data to SicsthSense