2012-04-27 18:33:46 Script Error tempalert.py: <urlopen error (60, 'Operation timed out')>
2012-04-27 18:33:46 Script Error Exception Traceback (most recent call shown last):
tempalert.py, line 9, 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 (60, 'Operation timed out')>
This is my script;
- Code: Select all
import urllib2
import xml.etree.cElementTree as ET
#make a variable to hold the name of the file that was written to
file_name = "/tmp/xmlfeed.rb"
#location of temp alert file
url = "http://10.0.1.2/xmlfeed.rb"
response = urllib2.urlopen(url)
#open a local file for writing
local_file = open("/tmp/xmlfeed.rb", "w")
#read from request while writing to file
local_file.write(response.read())
local_file.close()
#location of the file to be parsed
content = ET.ElementTree(file="/tmp/xmlfeed.rb")
ports = content.find("ports")
#get all the port elements
for port in ports.findall('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)