#!c:\Program Files\Python39\python.exe # -*- coding: UTF-8 -*- ''' $RCSfile: details.py,v $ $Revision$ $Author: markus $ $Date$ The BioCASE querytool ''' import os, sys # ***** include the biocase.lib directory in the python sys path for importing ***** exec(open(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, 'lib', 'biocase', 'adjustpath.py'))).read()) # exec(compile(open( os.path.abspath( os.path.join( os.path.dirname( __file__ ), os.pardir, os.pardir, 'lib', 'biocase', 'appinit.py' ) ), "rb").read(), os.path.abspath( os.path.join( os.path.dirname( __file__ ), os.pardir, os.pardir, 'lib', 'biocase', 'appinit.py' ) ), 'exec')) # import pydevd; pydevd.settrace(); from biocase.querytool.general import form, schemaObj, wrapper_url, logDiagnostics from biocase.querytool.filter import createFilterObjFromString from biocase.querytool.querydispatcher import QueryDispatcher from biocase.querytool.querygenerator import QueryGenerator import logging log = logging.getLogger("querytool.raw") log.info("ORIGINAL FILTER STRING: %s" % form['filter'].value) filterObj = createFilterObjFromString(form['filter'].value, schemaObj) log.info("FILTER OBJ: %s" % filterObj) # generate the protocol QG = QueryGenerator() protocolXML = QG.getSearchProtocol(NS=schemaObj.NS, respNS=schemaObj.NS, count=False, filterObj=filterObj, destination=wrapper_url) log.info("QUERY PROTOCOL CREATED:\n%s" % protocolXML) # query the wrapper QD = QueryDispatcher() recStatus = QD.sendQuery(wrapper_url, protocolXML) content = QD.getContent(pretty=True) logDiagnostics(QD.getDiagnostics()) log.debug("WRAPPER CONTENT FOUND::::::::::::::::::") log.debug(content) if content is None: # no wrapper results found log.info("ERROR: NO PROTOCOL CONTENT FOUND") print('Content-Type: text/plain; charset=utf-8\n\n') print('-----------------------------') print('There was no wrapper result !') print('Please check debug log.') print('-----------------------------') else: sys.stdout.buffer.write('Content-Type: text/xml; charset=utf-8 \n\n'.encode('utf8')) sys.stdout.buffer.write(content)