大家好,我正在尝试通过mysql服务发送我的温度和湿度传感器,我需要将数据解析到php.wsdl web服务中,以便将数据从web服务插入到MySQL数据库中。
我遇到了一些关于的问题,请告诉我
这是我的脚本:
#!/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()这是遇到的错误
回溯(最近一次调用):
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
发布于 2014-02-07 17:50:38
@user1449266是对的。
你需要把你的
import subprocess在文件的开头:
#...
import time
import subprocess
from suds.client import Client
#...然后,子流程模块在名称subprocess下是已知的,并且在编写subprocess.check_output时,将找到子流程的属性check_output。
https://stackoverflow.com/questions/21621155
复制相似问题