|
From: <ki...@us...> - 2003-04-09 14:17:56
|
Update of /cvsroot/pymerase/pymerase/pymweb/cgi
In directory sc8-pr-cvs1:/tmp/cvs-serv19827/cgi
Modified Files:
pymweb.py
Log Message:
Added support for parseGenexSchemaXML input module =o)
Index: pymweb.py
===================================================================
RCS file: /cvsroot/pymerase/pymerase/pymweb/cgi/pymweb.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** pymweb.py 9 Apr 2003 01:38:50 -0000 1.8
--- pymweb.py 9 Apr 2003 14:17:53 -0000 1.9
***************
*** 38,44 ****
import tempfile
import re
! def getDriverScript(dest, compress):
! if compress == 'Tar&Gzip':
text = """#!/bin/bash
export CLASSPATH=/home/king/downloads/novasoft/nsuml-0.4.19.jar:/usr/share/java/xerces.jar
--- 38,45 ----
import tempfile
import re
+ import glob
! def getDriverScript(dest, compress, inputMod):
! if compress == 'Tar&Gzip' and inputMod == "parseXMI":
text = """#!/bin/bash
export CLASSPATH=/home/king/downloads/novasoft/nsuml-0.4.19.jar:/usr/share/java/xerces.jar
***************
*** 47,51 ****
tar cvzf %s.tar.gz %s > /dev/null
""" % (DIRPATH, dest, dest)
! elif compress == 'Zip':
text = """#!/bin/bash
export CLASSPATH=/home/king/downloads/novasoft/nsuml-0.4.19.jar:/usr/share/java/xerces.jar
--- 48,52 ----
tar cvzf %s.tar.gz %s > /dev/null
""" % (DIRPATH, dest, dest)
! elif compress == 'Zip' and inputMod == "parseXMI":
text = """#!/bin/bash
export CLASSPATH=/home/king/downloads/novasoft/nsuml-0.4.19.jar:/usr/share/java/xerces.jar
***************
*** 54,57 ****
--- 55,71 ----
zip %s.zip %s > /dev/null
""" % (DIRPATH, dest, dest)
+ elif compress == 'Tar&Gzip' and inputMod == 'parseGenexSchemaXML':
+ text = """#!/bin/bash
+ cd %s
+ python ./driver.py > /dev/null
+ tar cvzf %s.tar.gz %s > /dev/null
+ """ % (DIRPATH, dest, dest)
+ elif compress == 'Zip' and inputMod == 'parseGenexSchemaXML':
+ text = """#!/bin/bash
+ cd %s
+ python ./driver.py > /dev/null
+ zip %s.zip %s > /dev/null
+ """ % (DIRPATH, dest, dest)
+
else:
raise ValueError, 'Compression type of %s is invalid.' % (compress)
***************
*** 87,90 ****
--- 101,112 ----
+ def getDecompress(fileName):
+ text = """#!/bin/bash
+ tar xzf %s
+ """ % (fileName)
+
+ return text
+
+
ROOTPATH = '/tmp/pymweb'
if not os.path.exists(ROOTPATH):
***************
*** 109,112 ****
--- 131,152 ----
+ def processSchemaXML(schemaPath):
+ obj = re.compile('SYSTEM \".*\"')
+
+ xmlSearch = os.path.join(schemaPath[:-7], '*.xml')
+ fileList = glob.glob(xmlSearch)
+
+ for file in fileList:
+ f = open(file, 'r')
+ xmlFile = f.read()
+ f.close()
+
+ xmlFile = obj.sub('SYSTEM \"http://localhost/table.dtd\"', xmlFile)
+
+ f = open(file, 'w')
+ f.write(xmlFile)
+ f.close()
+
+
def saveFile(fileName, file):
***************
*** 117,120 ****
--- 157,179 ----
f.close()
+ if fileName[-7:] == '.tar.gz':
+ curPath = os.getcwd()
+ os.chdir(DIRPATH)
+
+ untarPath = os.path.join(DIRPATH, 'untar.sh')
+
+ f = open(untarPath, 'w')
+ f.write(getDecompress(fileName))
+ f.close()
+
+ os.chmod(untarPath, 0755)
+
+ errCode = os.spawnl(os.P_WAIT, 'untar.sh', 'untar.sh')
+ #print 'Decompress Exit Code: %s<br><br>' % \
+ # (errCode)
+ if str(errCode) == '0':
+ processSchemaXML(filePath)
+
+ os.chdir(curPath)
return filePath
***************
*** 140,144 ****
def checkDest(dest):
! block = ['\\', '/', '..']
for item in block:
--- 199,203 ----
def checkDest(dest):
! block = ['\\', '/']
for item in block:
***************
*** 175,179 ****
fileName = checkFileName(fileName)
! saved = saveFile(fileName, file.file.read())
#print 'File %s saved.<br><br>' % (saved)
--- 234,238 ----
fileName = checkFileName(fileName)
! saved = saveFile(fileName, file.file.read())
#print 'File %s saved.<br><br>' % (saved)
***************
*** 201,209 ****
html += text
text = '<b>Destination:</b> %s<br>\n' % (dest)
print text
html += text
! if checkDest == 1:
pass
else:
--- 260,281 ----
html += text
+ if fileName[-7:] == '.tar.gz':
+ uploadedFile = fileName
+ fileName = fileName[:-7]
+
+ if os.path.isdir(os.path.join(DIRPATH, fileName)):
+ #tar xvzf fileName worked
+ pass
+ else:
+ text = "Error: %s does not exist, is %s a valid file?<br>" % \
+ (fileName, uploadedFile)
+ print text
+ raise ValueError, text
+
text = '<b>Destination:</b> %s<br>\n' % (dest)
print text
html += text
! if checkDest(dest) == 1:
pass
else:
***************
*** 227,231 ****
driverPath = saveFile('driver.py', driver)
! script = getDriverScript(dest, compression)
scriptPath = saveFile('driver.sh', script)
--- 299,303 ----
driverPath = saveFile('driver.py', driver)
! script = getDriverScript(dest, compression, input)
scriptPath = saveFile('driver.sh', script)
|