#!c:\Program Files\Python39\python.exe # -*- coding: UTF-8 -*- import os, sys, hashlib # ***** 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()) from biocase.configtool.general import dsa, dsaObj, authorize, form, printOverHTTP, templateDir from biocase.tools.templating import PageMacro from biocase import __version__ import biocase.configuration cfg = biocase.configuration.Cfg() # check authentication! if dsaObj 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) # check archive folders dldPath = os.path.join(cfg.archiveDownloadLocator, dsa) archivePath = os.path.join(cfg.archiveWorkLocator, dsa) if not os.path.exists(archivePath): os.makedirs(archivePath) if not os.path.exists(dldPath): os.makedirs(dldPath) # load html template tmpl = PageMacro('Content', PageMacro.DELMODE) tmpl.load('Content', os.path.join(templateDir, '_archive.html')) # Create ticket (encoded pw) psfObj = dsaObj.getPSFObj(tmp=False) pw = psfObj.adminpassword if psfObj.adminpassword else cfg.server.adminpassword # fill template # general stuff tmpl['dsa'] = dsa tmpl['wrapper_url'] = dsaObj.getBioCASeAccessPoint() tmpl['ServiceTitle'] = 'BioCASe Provider Software %s' % __version__ tmpl['ticket'] = hashlib.md5(pw.encode()).hexdigest() slObj = dsaObj.getSchemaListObj() DsaSchemaList = [] for sObj in slObj: tmpl['disable'] = '' entry = {} entry['schema'] = sObj.name[:-4] entry['schema_file'] = os.path.split(sObj.file)[1] entry['namespace'] = sObj.NS entry['num_mappings'] = str(sObj.mappings) DsaSchemaList.append(entry) tmpl.expand('Content', 'schemalist', DsaSchemaList) printOverHTTP(tmpl)