示例#1
0
def main():
    form = cgi.FieldStorage()
    
    if not 'code' in form or not form['code']:
        raise Common.BiologicError('Han unicode value is missing')
    uchHan = form.getfirst('code').upper()

    if 'hcf' in form:
        pathHCF = Common.resolvePath('./../../Archetypes/' + Common.makeHanPath(uchHan + Common.Constants.extHCF))
        try:
            fileHCF = os.open(pathHCF, os.O_CREAT | os.O_TRUNC | os.O_WRONLY, 0664)
            os.write(fileHCF, form['hcf'].value)
            os.close(fileHCF)
        except IOError, err:
            raise Common.BiologicError('Unable to write %s - %s' % (pathHCF, str(err)))
            
        inscribe.setGlobals([ '-d', './../../Archetypes/', '-u', './../../Archetypes/' ])
        inscribe.buildHan(uchHan)

        inscribe.setGlobals([ '-o', './../../Genes/', '-u', './../../Archetypes/' ])
        aryGeneNames = inscribe.buildGenes(uchHan, [ 'default' ])
        returnMsg('Successfully created Han definition and default gene (%s) for %s' % (aryGeneNames[0], uchHan))
示例#2
0
    if not 'code' in form or not form['code']:
        raise Common.BiologicError('Han unicode value is missing')
    uchHan = form.getfirst('code').upper()

    if 'hcf' in form:
        pathHCF = Common.resolvePath('./../../Archetypes/' + Common.makeHanPath(uchHan + Common.Constants.extHCF))
        try:
            fileHCF = os.open(pathHCF, os.O_CREAT | os.O_TRUNC | os.O_WRONLY, 0664)
            os.write(fileHCF, form['hcf'].value)
            os.close(fileHCF)
        except IOError, err:
            raise Common.BiologicError('Unable to write %s - %s' % (pathHCF, str(err)))
            
        inscribe.setGlobals([ '-d', './../../Archetypes/', '-u', './../../Archetypes/' ])
        inscribe.buildHan(uchHan)

        inscribe.setGlobals([ '-o', './../../Genes/', '-u', './../../Archetypes/' ])
        aryGeneNames = inscribe.buildGenes(uchHan, [ 'default' ])
        returnMsg('Successfully created Han definition and default gene (%s) for %s' % (aryGeneNames[0], uchHan))
    
    if 'gene' in form:
        inscribe.setGlobals([ '-o', './../../Genes/', '-u', './../../Archetypes/' ])
        aryGeneNames = inscribe.buildGenes(uchHan, [ form.getfirst('gene') ])
        returnMsg('Successfully created gene - saved as %s' % aryGeneNames[0])

try:
    print 'Content-type: text/plain\n'
    main()
except Common.BiologicError, err:
    returnMsg('ERROR: %s' % str(err), True)