首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >DHT11温度/湿度传感器网络服务错误

DHT11温度/湿度传感器网络服务错误
EN

Stack Overflow用户
提问于 2014-02-07 14:52:35
回答 1查看 948关注 0票数 0

大家好,我正在尝试通过mysql服务发送我的温度和湿度传感器,我需要将数据解析到php.wsdl web服务中,以便将数据从web服务插入到MySQL数据库中。

我遇到了一些关于的问题,请告诉我

这是我的脚本:

代码语言:javascript
复制
#!/usr/bin/python
import time
from suds.client import Client

url = "http://172.20.xxx.xx``/SCS/WebService/webS.php?wsdl"
client = Client(url)



while(True):
# Run the DHT program to get the humidity and temperature readings!

    output = subprocess.check_output(["./Adafruit_DHT", "2302", "4"]);
    print output
    matches = re.search("Temp =\s+([0-9.]+)", output)
    if (not matches):
    time.sleep(3)
    continue
    temp = float(matches.group(1))
# search for humidity printout
    matches = re.search("Hum =\s+([0-9.]+)", output)
    if (not matches):
    time.sleep(3)
    continue
    humidity = float(matches.group(1))

    print "Temperature: %.1f C" % temp
    print "Humidity: %.1f %%" % humidity

# Append the data , including a timestamp
    try:
    values = [datetime.datetime.now(), temp, humidity]

    except:
    print "Unable to append data. Check your connection?"
    sys.exit()

这是遇到的错误

回溯(最近一次调用):

代码语言:javascript
复制
File "./websvc.py", line 13, in <module>
output = subprocess.check_output(["./Adafruit_DHT", "2302", "4"]);
NameError: name 'subprocess' is not defined

我正在尝试使用本教程/脚本中的python suds。请给我建议。http://bradsrpi.blogspot.sg/2013/03/raspberry-pi-soap-web-service-client.html

EN

回答 1

Stack Overflow用户

发布于 2014-02-07 17:50:38

@user1449266是对的。

你需要把你的

代码语言:javascript
复制
import subprocess

在文件的开头:

代码语言:javascript
复制
#...
import time
import subprocess
from suds.client import Client
#...

然后,子流程模块在名称subprocess下是已知的,并且在编写subprocess.check_output时,将找到子流程的属性check_output

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21621155

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档