#!c:\Program Files\Python39\python.exe # -*- coding: UTF-8 -*- ''' $RCSfile: dbconnection.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(open(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, 'lib', 'biocase', 'appinit.py'))).read()) # import pydevd; pydevd.settrace(); from biocase.configtool.general import dsa, authorize, form, dsaObj, templateDir, log, getDBMSList, getDropDownOptionHtml, getEncodingList, printOverHTTP from biocase.tools.templating import PageMacro from biocase import __version__ ############################################################################################################ # # MAIN # #=========================================================================================================== # check authentication! if dsa is None: exec(open(os.path.abspath(os.path.join(os.path.dirname(__file__), 'main.cgi'))).read()) sys.exit() # check authentication! authorize(form, dsa=dsa) # load html template tmpl = PageMacro('Content', PageMacro.DELMODE) tmpl.load('Content', os.path.join(templateDir, '_dbconnection.html')) # # get psfObj # psfObj = dsaObj.getPSFObj(tmp=False) # # look for new form values # if 'action' in form: if form['action'].value == 'Save': psfObj.dbIP = form.getfirst('host', None) psfObj.database = form.getfirst('database', None) psfObj.user = form.getfirst('user', None) psfObj.password = form.getfirst('password', None) psfObj.dbms = form.getfirst('dbms', None) psfObj.encoding = form.getfirst('encoding', None) psfObj.writePSFile() log.debug("PSFile written") # # fill template # # general stuff tmpl['dsa'] = dsa tmpl['wrapper_url'] = dsaObj.getBioCASeAccessPoint() tmpl['ServiceTitle'] = 'BioCASe Provider Software %s' % __version__ # dbconnection status log.debug("Get DBConnectionStatus") tmpl['status'] = dsaObj.getDBConnectionStatus() # list of available dbms modules dbmsList = getDBMSList() if psfObj.dbms is not None: # dbms already selected dropDown = getDropDownOptionHtml(dbmsList, psfObj.dbms) else: dropDown = getDropDownOptionHtml(['--select--'] + dbmsList, '--select--') tmpl['dbms_optionlist'] = dropDown # list of available encodings encList = getEncodingList() if psfObj.encoding is not None: # encoding already selected dropDown = getDropDownOptionHtml(encList, psfObj.encoding) else: dropDown = getDropDownOptionHtml(['--select--'] + encList, '--select--') tmpl['encoding_optionlist'] = dropDown # connection parameters tmpl['host'] = psfObj.dbIP tmpl['database'] = psfObj.database tmpl['user'] = psfObj.user tmpl['password'] = psfObj.password # # print HTML ! # printOverHTTP( tmpl )