Commit f00719f8 authored by kpetersn's avatar kpetersn
Browse files

Added test.py, a script to troubleshoot why an.py stopped working when called from cron on OS X.

parent d57cfe10
#!/usr/bin/env python
import urllib
import xml.etree.ElementTree as ET
import os
alive_url = "http://bcda.xray.aps.anl.gov/cgi-bin/alivexml.cgi"
# function for troubleshooting
def get_xml(alive_url):
# Get the xml file
print "Opening URL"
try:
f = urllib.urlopen(alive_url)
print "Reading XML from URL"
xml_string = f.read()
except IOError:
print "Couldn't open URL"
xml_string = None
#else:
print "Closing URL"
f.close()
return xml_string
def open_xml(xml_string):
try:
root = ET.fromstring(xml_string)
except ET.ParseError:
print "Invalid XML file"
retval = xml_string
else:
print "XML file OK"
retval = "OK"
#!retval = xml_string
return retval
def xml_test(alive_url):
xml_string = get_xml(alive_url)
if xml_string != None:
print open_xml(xml_string)
print "uid = %i, gid = %i" % (os.getuid(), os.getgid())
xml_test(alive_url)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment