0

谁能告诉我为什么我会收到这些错误?

Script Error  tempAlert.py: <urlopen error timed out>
Script Error  Exception Traceback (most recent call shown last):

 tempAlert.py, line 16, at top level
 File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 124, in urlopen
   return _opener.open(url, data)
 File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 381, in open
   response = self._open(req, data)
 File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 399, in _open
   '_open', req)
 File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 360, in _call_chain
   result = func(*args)
 File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 1118, in http_open
   return self.do_open(httplib.HTTPConnection, req)
 File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py", line 1093, in do_open
   raise URLError(err)
URLError: <urlopen error timed out>

这是脚本:

import xml.etree.cElementTree as ET
from xml.etree.cElementTree import parse 
import urllib2
import string
import re
import socket
import time

socket.setdefaulttimeout(40)

#set prevTemp to last temp
prevAlertTemp = indigo.variables[77213772]
indigo.variable.updateValue(794594968, prevAlertTemp.value)

url = "http://10.0.1.2/xmlfeed.rb"
tree = parse(urllib2.urlopen(url))

#get all the port elements
for port in tree.findall("ports/port"):

if port.get('name') == 'Port 1': 
  currentTemp = port.find("condition/currentReading")
  indigo.variable.updateValue("tAlertTemp_", currentTemp.text)

elif port.get('name') == 'Port 2': 

currentTemp = port.find("condition/currentReading")
indigo.variable.updateValue("tAlertTemp2_", currentTemp.text)

indigo.variable.updateValue(865541269, time.strftime( "%H:%M %a %d %b"))
4

1 回答 1

0

Your connection times out, so there is probably no service listening at http://10.0.1.2/xmlfeed.rb

于 2013-03-28T05:31:59.617 回答