#!c:\Program Files\Python39\python.exe ''' $RCSfile: $ $Revision$ $Author: j.holetschek $ $Date$ ''' # **************************************** # +++ BioCASE # +++ pywrapper # # See http://www.biocase.org for details # # **************************************** import sys, os.path, urllib # ***** include the biocase.lib directory in the python sys path for module importing ***** exec(open(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, 'lib', 'biocase', 'adjustpath.py'))).read()) import biocase.configuration cfg = biocase.configuration.Cfg() import logging, biocase.initlogs log = logging.getLogger("pywrapper") from biocase.wrapper.pywrapper import pywrapper #import pydevd; pydevd.settrace() # get datasource alias from GET querystring if "QUERY_STRING" in os.environ: QS = urllib.parse.parse_qs(os.environ["QUERY_STRING"]) # Inventory parameter: Requests the dataset inventory to be returned; no BioCASe protocol usage if 'inventory' in QS: inventory = True if QS['inventory'][0] in ('1', 'true', 'True') else False else: inventory = False if 'dsa' in QS: dsa = QS['dsa'][0] elif 'DSA' in QS: dsa = QS['DSA'][0] elif 'datasource' in QS: dsa = QS['datasource'][0] else: sys.stdout.write('Content-Type: text/plain\n\nNo Datasource alias given!') sys.exit() else: sys.stdout.write('Content-Type: text/plain\n\n') sys.exit("No querystring given. Pass at least a datasource alias via dsa=XXX!") biocase.initlogs.initWrapperLogging(dsa) try: # If dataset inventory is requested, the protocol to None; otherwise biocase if inventory: pywInstance = pywrapper(None, dsa=dsa) else: pywInstance = pywrapper('biocase', dsa=dsa) except Exception as ex: sys.stdout.write('Content-Type: text/plain\n\n%s' % ex.msg) sys.exit() # create a request from CGI log.debug("pywInstance.parseRequest...") pywInstance.parseRequest() # print the result to the stream log.debug("pywInstance.doResponse...") pywInstance.doResponse(httpHeader=1) # log.info(sys.stdout.encoding) log.info("PyWrapper response successful")