|
From: <ki...@us...> - 2003-05-30 02:00:56
|
Update of /cvsroot/pymerase/pymerase/pymweb/cgi
In directory sc8-pr-cvs1:/tmp/cvs-serv24966
Modified Files:
pymweb.py
Log Message:
now launches pymerase directly instead of calling from shell script
now gives more meaningful error messages when it crashes
Index: pymweb.py
===================================================================
RCS file: /cvsroot/pymerase/pymerase/pymweb/cgi/pymweb.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** pymweb.py 30 Apr 2003 19:10:52 -0000 1.14
--- pymweb.py 30 May 2003 02:00:50 -0000 1.15
***************
*** 34,42 ****
import pymerase
- import cgi
import os
import tempfile
import re
import glob
rev = "$Revision$"
--- 34,44 ----
import pymerase
import os
import tempfile
import re
import glob
+ import cgi
+ import cgitb
+ cgitb.enable()
rev = "$Revision$"
***************
*** 46,86 ****
VERSION = '0.%s' % (rev)
! def getDriverScript(dest, compress, inputMod):
! if compress == 'Tar&Gzip' and inputMod == "parseXMI":
! text = """#!/bin/bash
! export PYTHONPATH=/home/king/proj/smw
! cd %s
! python ./driver.py > /dev/null
! if [ -e %s ] ; then
! tar cvzf %s.tar.gz %s > /dev/null
! else
! cat %s.bs
! fi
! """ % (DIRPATH, dest, dest, dest, dest)
!
! elif compress == 'Zip' and inputMod == "parseXMI":
! text = """#!/bin/bash
! export PYTHONPATH=/home/king/proj/smw
! cd %s
! python ./driver.py > /dev/null
! if [ -e %s ] ; then
! zip %s.zip %s > /dev/null
! else
! cat %s.bs
! fi
! """ % (DIRPATH, dest, dest, dest, dest)
!
! elif compress == 'None' and inputMod == 'parseXMI':
! text = """#!/bin/bash
! export PYTHONPATH=/home/king/proj/smw
! cd %s
! python ./driver.py > /dev/null
!
! """ % (DIRPATH)
!
! elif compress == 'Tar&Gzip' and inputMod == 'parseGenexSchemaXML':
text = """#!/bin/bash
cd %s
- python ./driver.py > /dev/null
if [ -e %s ] ; then
tar cvzf %s.tar.gz %s > /dev/null
--- 48,55 ----
VERSION = '0.%s' % (rev)
! def getCompressionScript(dest, compress):
! if compress == 'Tar&Gzip':
text = """#!/bin/bash
cd %s
if [ -e %s ] ; then
tar cvzf %s.tar.gz %s > /dev/null
***************
*** 90,97 ****
""" % (DIRPATH, dest, dest, dest, dest)
! elif compress == 'Zip' and inputMod == 'parseGenexSchemaXML':
text = """#!/bin/bash
cd %s
- python ./driver.py > /dev/null
if [ -e %s ] ; then
zip %s.zip %s > /dev/null
--- 59,65 ----
""" % (DIRPATH, dest, dest, dest, dest)
! elif compress == 'Zip':
text = """#!/bin/bash
cd %s
if [ -e %s ] ; then
zip %s.zip %s > /dev/null
***************
*** 101,111 ****
""" % (DIRPATH, dest, dest, dest, dest)
! elif compress == 'None' and inputMod == 'parseGenexSchemaXML':
! text = """#!/bin/bash
! cd %s
! python ./driver.py > /dev/null
!
! """ % (DIRPATH)
!
else:
raise ValueError, 'Compression type of %s is invalid.' % (compress)
--- 69,75 ----
""" % (DIRPATH, dest, dest, dest, dest)
! elif compress == 'None':
! return None
!
else:
raise ValueError, 'Compression type of %s is invalid.' % (compress)
***************
*** 113,140 ****
return text
- def getDriverProgram(input, output, schema, dest):
- temp = """#!/usr/bin/env python2.2
-
- import sys
- import os
-
- import pymerase
! if __name__ == \"__main__\":
! schema = os.path.abspath(\"%schema%\")
! outputPath = os.path.abspath(\"%dest%\")
pymerase.run(schema,
! \"%input%\",
outputPath,
! \"%output%\")
! """
!
! temp = re.sub('%input%', input, temp)
! temp = re.sub('%output%', output, temp)
! temp = re.sub('%schema%', os.path.join(DIRPATH, schema), temp)
! temp = re.sub('%dest%', os.path.join(DIRPATH, dest), temp)
! return temp
--- 77,96 ----
return text
! def launchPymerase(input, output, schema, dest):
! import sys
! import os
!
! import pymerase
!
! schema = os.path.abspath(os.path.join(DIRPATH, schema))
! outputPath = os.path.abspath(os.path.join(DIRPATH, dest))
pymerase.run(schema,
! input,
outputPath,
! output)
! return 0
***************
*** 240,245 ****
fileName = fileName[:-7]
! if fileName == 'driver.sh' \
! or fileName == 'driver.py' \
or fileName == 'index.html' \
or fileName == 'untar.sh':
--- 196,200 ----
fileName = fileName[:-7]
! if fileName == 'cmp.sh' \
or fileName == 'index.html' \
or fileName == 'untar.sh':
***************
*** 255,260 ****
return 0
! if dest == 'driver.sh' \
! or dest == 'driver.py' \
or dest == 'index.html' \
or dest == 'untar.sh':
--- 210,214 ----
return 0
! if dest == 'cmp.sh' \
or dest == 'index.html' \
or dest == 'untar.sh':
***************
*** 354,380 ****
html += text
! driver = getDriverProgram(input,
! output,
! fileName,
! dest)
!
! driverPath = saveFile('driver.py', driver)
!
! script = getDriverScript(dest, compression, input)
! scriptPath = saveFile('driver.sh', script)
!
! fullPath = os.path.join(DIRPATH, scriptPath)
! #print "<br>Processing %s<br>" % (fullPath)
! os.chmod(fullPath, 0755)
! text = os.spawnl(os.P_WAIT, fullPath, fullPath)
! #print '-----<br>'
! #print 'driver.sh exit code:', text, '<br>'
! #print '-----<br>'
!
! #if str(text) == '127':
! # debug()
if str(text) != '0':
text = 'ERROR, exit code %s<br>\n' % (text)
--- 308,333 ----
html += text
! ##############################
! # Launch Pymerase
! ##############################
! rv = launchPymerase(input, output, fileName, dest)
! if rv != 0:
! raise ValueError, 'Pymweb broke badly'
! ##############################
! # Compress Output if Requested
! ##############################
! compressScript = getCompressionScript(dest, compression)
+ if compressScript is not None:
+ cmpScriptPath = saveFile('cmp.sh', compressScript)
+ fullCmpPath = os.path.join(DIRPATH, cmpScriptPath)
+ os.chmod(fullCmpPath, 0755)
+ text = os.spawnl(os.P_WAIT, fullCmpPath, fullCmpPath)
+ else:
+ #compress type is None, don't compress
+ text = 0
+
if str(text) != '0':
text = 'ERROR, exit code %s<br>\n' % (text)
|