Changeset 4055
- Timestamp:
- 21/07/08 12:04:50 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI02-CSML/trunk/csml/webparser/parseTest.py
r4044 r4055 1 1 #!/usr/bin/python 2 import logging 3 logging.basicConfig(level=logging.DEBUG, filename='logs/parser2.log') 2 4 import cgi 3 5 from cElementTree import * … … 7 9 import elementtree.ElementTree as etree 8 10 import traceback 11 logging.debug('imports all ok') 12 9 13 """Test for GML/CSML parsing code 10 14 """ … … 82 86 83 87 def main(): 88 logging.debug('starting main') 84 89 sys.stderr = sys.stdout 85 90 print "Content-type: text/html" … … 96 101 print "<h1>CSML Version 2 Test Parser</h1>" 97 102 print "<p>Please note this is experimental, any questions please contact d.lowe@rl.ac.uk</p>" 98 print "<p>Parser version - 28 February 2007 - includes NDG security elements, fixed unicode encoding</p>" 99 print "<h2>Load a CSML file to test:</h2>" 103 print "<p>Parser version - 18 July 2008 - moved to new server and update parser to latest from svn</p>" 104 print "<h2>Load a CSML file to test against the parser:</h2>" 105 logging.debug('ready to load form') 100 106 form= cgi.FieldStorage() 107 logging.debug('initialised form %s'%form) 101 108 if not form: 102 print """<form action="http://glue.badc.rl.ac.uk/cgi-bin/csml2/parseTest.py" method="POST" enctype="multipart/form-data"> <input type="file" name="filename"> <input type="submit"></form>""" 109 logging.debug('not form') 110 print """<form action="http://csml.badc.rl.ac.uk/cgi-bin/parseTest.py" method="POST" enctype="multipart/form-data"> <input type="file" name="filename"> <input type="submit"></form>""" 103 111 elif form.has_key("filename"): 104 112 item = form["filename"] … … 107 115 #print cgi.escape(data) 108 116 #data1 = cgi.escape(data) 109 f = open(" /tmp/tempcsml.xml","wb")117 f = open("temp/tempcsml.xml","wb") 110 118 f.write(data) 111 119 f.close() … … 122 130 # 1. Test parsing from CSML file 123 131 try: 124 tree = ElementTree(file=' /tmp/tempcsml.xml')132 tree = ElementTree(file='temp/tempcsml.xml') 125 133 except: 126 134 traceback.print_exc() … … 134 142 except: 135 143 traceback.print_exc() 136 print "<p>Could not parse CSM , problem reading XML into objects.</p>"144 print "<p>Could not parse CSML, problem reading XML into objects.</p>" 137 145 sys.exit() 138 146 … … 162 170 break 163 171 print "</HEAD>" 172 logging.debug('end of main') 164 173 main() 165 174
Note: See TracChangeset
for help on using the changeset viewer.