128 lines
3.5 KiB
Python
Executable File
128 lines
3.5 KiB
Python
Executable File
#!/usr/bin/env /usr/bin/python3
|
|
|
|
import cgi, os
|
|
import cgitb
|
|
import subprocess
|
|
|
|
cgitb.enable()
|
|
|
|
form = cgi.FieldStorage()
|
|
|
|
fn1=""
|
|
fn2=""
|
|
fn3=""
|
|
fn4=""
|
|
fn5=""
|
|
|
|
message1=""
|
|
message2=""
|
|
message3=""
|
|
message4=""
|
|
|
|
fileitem = form['filename1']
|
|
if fileitem.filename:
|
|
fn1 = os.path.basename(fileitem.filename)
|
|
if fn1.endswith('.txt') :
|
|
open('files/' + fn1, 'wb').write(fileitem.file.read())
|
|
message1 = 'The file "' + fn1 + '" was uploaded successfully'
|
|
else:
|
|
message1 = 'Need to be a txt file'
|
|
fn1 = ""
|
|
else:
|
|
message1 = 'No file was uploaded'
|
|
|
|
fileitem = form['filename2']
|
|
if fileitem.filename:
|
|
fn2 = os.path.basename(fileitem.filename)
|
|
if fn2.endswith('.txt') :
|
|
open('files/' + fn2, 'wb').write(fileitem.file.read())
|
|
message2 = 'The file "' + fn2 + '" was uploaded successfully'
|
|
else:
|
|
message2 = 'Need to be a txt file'
|
|
fn2 = ""
|
|
else:
|
|
message2 = 'No file was uploaded'
|
|
|
|
fileitem = form['filename3']
|
|
if fileitem.filename:
|
|
fn3 = os.path.basename(fileitem.filename)
|
|
if fn3.endswith('.txt') :
|
|
open('files/' + fn3, 'wb').write(fileitem.file.read())
|
|
message3 = 'The file "' + fn3 + '" was uploaded successfully'
|
|
else:
|
|
message3 = 'Need to be a txt file'
|
|
fn3 = ""
|
|
else:
|
|
message3 = 'No file was uploaded'
|
|
|
|
fileitem = form['filename4']
|
|
if fileitem.filename:
|
|
fn4 = os.path.basename(fileitem.filename)
|
|
if fn4.endswith('') :
|
|
open('files/' + fn4, 'wb').write(fileitem.file.read())
|
|
message4 = 'The file "' + fn4 + '" was uploaded successfully'
|
|
else:
|
|
message4 = 'Need to be empty extension file'
|
|
fn4 = ""
|
|
else:
|
|
message4 = 'No file was uploaded'
|
|
|
|
fileitem = form['filename5']
|
|
if fileitem.filename:
|
|
fn5 = os.path.basename(fileitem.filename)
|
|
if fn5.endswith('.txt') :
|
|
open('files/' + fn5, 'wb').write(fileitem.file.read())
|
|
message5 = 'The file "' + fn5 + '" was uploaded successfully'
|
|
else:
|
|
message5 = 'Need to be a txt file'
|
|
fn5 = ""
|
|
else:
|
|
message5 = 'No file was uploaded'
|
|
|
|
##change to files directory
|
|
os.chdir(r"files")
|
|
|
|
pngName=""
|
|
result=""
|
|
haha=""
|
|
dwba_1=""
|
|
dwba_2=""
|
|
|
|
#------- if only DWBA
|
|
if fn4!="" :
|
|
dwba_1 = subprocess.run(["../Cleopatra/InFileCreator", fn4, "0", "180", "0.1"] , stdout=subprocess.PIPE).stdout.decode('utf-8')
|
|
#result = dwbs_1.find('.in')
|
|
|
|
|
|
#dwba_2 = subprocess.run(["../Cleopatra/ptolemy", , "0", "180", "0.1"] , stdout=subprocess.PIPE).stdout.decode('utf-8')
|
|
|
|
'''
|
|
if fn1=="" or fn2=="" or fn3=="" :
|
|
result = "imcomplete input files"
|
|
pngName = ""
|
|
haha = ""
|
|
else:
|
|
result = subprocess.run(["../Cleopatra/Transfer", fn1, fn2, fn3, "0"], stdout=subprocess.PIPE).stdout.decode('utf-8')
|
|
haha = subprocess.run(["../Cleopatra/PlotSimulation", "transfer.root"], stdout=subprocess.PIPE).stdout.decode('utf-8')
|
|
pngName=haha.splitlines().pop()
|
|
'''
|
|
|
|
print ("Content-Type: text/html\r\n\r\n")
|
|
print ("<html>")
|
|
print ("<style> img {max-width: 100%} </style>")
|
|
print ("<style> body { font-family: courier, courier new, serif;} </style>")
|
|
print ("<body>")
|
|
if pngName != "" :
|
|
print ("<img src=\"files/%s\">" % pngName)
|
|
|
|
print ("<br>Reaction File : %s" % message1)
|
|
print ("<br>DetectorGeo File : %s" % message2)
|
|
print ("<br>Ex File : %s" % message3)
|
|
print ("<br>DWBA File : %s" % message4)
|
|
print ("<br>Plot Config File : %s" % message5)
|
|
print ("<br><span style=\"white-space: pre-line\"> %s </span>" % dwba_1)
|
|
print ("<br><span style=\"white-space: pre-line\"> %s </span>" % result)
|
|
print ("<br><span style=\"white-space: pre-line\"> %s </span>" % haha)
|
|
print ("</body>")
|
|
print ("</html>")
|