#!c:\Program Files\Python39\python.exe # -*- coding: UTF-8 -*- ''' $RCSfile: check_errors.cgi,v $ $Revision$ $Author: j.torre $ $Date$ The BioCASE TestingTool ''' # ***** include the biocase.lib directory in the python sys path for importing ***** import os, sys exec(open(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, 'lib', 'biocase', 'adjustpath.py'))).read()) #Import some stuff----------------------------------------- import cgitb; cgitb.enable() import cgi import string import os, sys import inspect as _i import os as _os import os.path as _p import urllib.request, urllib.parse, urllib.error from xml.etree import ElementTree import biocase.configuration import logging, biocase.initlogs biocase.initlogs.initWebappLogging() # get config data cfg=biocase.configuration.Cfg() # Take parameters form = cgi.FieldStorage() #First query the wrapper with the XML sent wrapper_url = cfg.getAccessPoint(form['dsa'].value) protocolXML = form['search'].value errors=[] try: params = urllib.parse.urlencode({'query': protocolXML, 'debug':form['debug'].value}) source = urllib.request.urlopen(wrapper_url, params) except: errors.append("Can't open wrapper URL %s" % wrapper_url) # Use Elementtree to parse XML try: for event, elem in ElementTree.iterparse(source): if elem.tag=='diagnostic' and 'severity' in elem.attrib and elem.attrib['severity']=="error": errors.append(elem.text) elem.clear() except: errors.append("Can't parse wrapper response. Seems to be no valid XML") try: errors.append("RESPONSE:\n%s" % data) except: pass #Print the headers print('Content-Type: text/html; charset=UTF-8') print() # Blank line marking end of HTTP headers print('''''') if (len(errors)<1): print('

No Errors detected