我正在this site上做练习。我完全遵循了这个示例,并且没有任何问题,直到我了解了上下文订阅:
(curl localhost:1026/v1/subscribeContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' -d @- | python -mjson.tool) <<EOF
{
"entities": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1"
}
],
"attributes": [
"temperature"
],
"reference": "http://localhost:1028/accumulate",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONTIMEINTERVAL",
"condValues": [
"PT10S"
]
}
]
}
EOF
当我输入代码时,我得到了预期的答案:
{
"subscribeResponse": {
"duration": "P1M",
"subscriptionId": "51c04a21d714fb3b37d7d5a7"
}
}
但这句话让我很困惑:
If you look at the accumulator-script.py terminal window, you will see that a message resembling the following one is received each 10 seconds:
我在这里要做的是输入以下命令:python accumulator-server.py
但是我得到的输出(每10秒更新一次)是:127.0.0.1 - - [08/Apr/2015 10:52:56] "POST /accumulate HTTP/1.1" 200 -
因为我没有像教程中提到的那样获得预期的输出,所以我在这里遗漏了什么吗?你知道吗
POST http://localhost:1028/accumulate
Content-Length: 492
User-Agent: orion/0.9.0
Host: localhost:1028
Accept: application/xml, application/json
Content-Type: application/json
{
"subscriptionId" : "51c04a21d714fb3b37d7d5a7",
"originator" : "localhost",
"contextResponses" : [
{
"contextElement" : {
"attributes" : [
{
"name" : "temperature",
"type" : "float",
"value" : "26.5"
}
],
"type" : "Room",
"isPattern" : "false",
"id" : "Room1"
},
"statusCode" : {
"code" : "200",
"reasonPhrase" : "OK"
}
}
]
}
我是否没有正确运行python脚本?顺便说一句,我对python和linux都是新手。。。你知道吗
根据the manual,累加器的运行方式如下:
相关问题 更多 >
编程相关推荐