#!c:\Program Files\Python39\python.exe
# -*- coding: UTF-8 -*-
'''
$RCSfile: index.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 string
import os, sys
import inspect as _i
import os as _os
import os.path as _p
import cgi
#-------------------------------------------------------------
import biocase.configuration
import logging, biocase.initlogs
biocase.initlogs.initWebappLogging()
import biocase.tools.templating
from biocase.tools.htmltools import getDropDownOptionHtml
import biocase.datasources
# get config data
cfg=biocase.configuration.Cfg()
#Get the dsa parameter
form = cgi.FieldStorage()
#------------------------------------------------------------------------------------
#Prepare the template
pm = biocase.tools.templating.PageMacro('Content', biocase.tools.templating.PageMacro.KEEPMODE)
pm.load('Content', os.path.join(cfg.wwwLocator,'testingtool', '_index.html'))
#Check that all necesary libraries are installed:
try:
import xml.etree.ElementTree
import biocase
import biocase.wrapper
pm['library_status'] = 'OK'
except:
pm['library_status'] = 'Wrong, check libraries'
#Print the headers
print('Content-Type: text/html; charset=UTF-8')
print() # Blank line marking end of HTTP headers
dsaList = biocase.datasources.getDsaList()
if len(dsaList)>0:
if 'dsa' in form:
dsa = form['dsa'].value
dsaObj = biocase.datasources.Datasource(dsa)
else:
# take first one from list
dsaObj = dsaList[0]
dsa = dsaObj.name
# dsa specific
pm['dsa'] = dsa
pm['DataSourcesOptionList'] = getDropDownOptionHtml([d.name for d in dsaList], default=dsa)
#Check that the database connection is fine
pm['db_con'] = dsaObj.getDBConnectionStatus()
else:
pm['warning_message']='There is no datasource configured.
Please create a new datasource first!'
print(pm)