can upload in file for Ptolemy

This commit is contained in:
Ryan@fsunuc 2022-12-09 17:40:02 -05:00
parent 4ca97d9a60
commit a674bd3cd5
2 changed files with 32 additions and 3 deletions

View File

@ -14,12 +14,14 @@ fn1=""
fn2=""
fn3=""
fn4=""
fn4a=""
fn5=""
message1=""
message2=""
message3=""
message4=""
message4a=""
message5=""
fileitem = form['filename1']
@ -70,6 +72,18 @@ if fileitem.filename:
else:
message4 = 'No file was uploaded'
fileitem = form['filename4a']
if fileitem.filename:
fn4a = os.path.basename(fileitem.filename)
if fn4a.endswith('.in') :
open('files/' + fn4a, 'wb').write(fileitem.file.read())
message4a = 'The file "' + fn4a + '" was uploaded successfully'
else:
message4a = 'Need to be in extension file'
fn4a = ""
else:
message4a = 'No file was uploaded'
fileitem = form['filename5']
if fileitem.filename:
fn5 = os.path.basename(fileitem.filename)
@ -103,11 +117,18 @@ dwbaRootFile=""
isTransferOK=False
#------- if only DWBA
if fn4!="" :
dwba_1 = subprocess.run(["../Cleopatra/InFileCreator", fn4, "0", "180", "0.1"] , stdout=subprocess.PIPE).stdout.decode('utf-8')
if fn4!="" or fn4a!="":
if fn4!="":
dwba_1 = subprocess.run(["../Cleopatra/InFileCreator", fn4, "0", "180", "0.1"] , stdout=subprocess.PIPE).stdout.decode('utf-8')
cmd = "../Cleopatra/ptolemy <%s.in> %s.out" % (fn4, fn4)
if fn4a!="":
fn4 = fn4a.split('.')[0]
cmd = "../Cleopatra/ptolemy <%s> %s.out" % (fn4a, fn4)
outFile = fn4+ ".out"
cmd = "../Cleopatra/ptolemy <%s.in> %s.out" % (fn4, fn4)
os.system(cmd)
isPtolemy = True
if os.path.exists(outFile) :
dwba_2 = outFile
dwba_3 = subprocess.run(["../Cleopatra/ExtractXSec", outFile, "1"], stdout=subprocess.PIPE).stdout.decode('utf-8')
@ -148,6 +169,9 @@ print ("<body>")
if dwbaPNG != "" :
print ("<img src=\"files/%s\">" % dwbaPNG)
print ("<br> Downlaod the <a href=\"files/%s\" download=\"%s\">%s</a>" % (fn4+".in", fn4+".in", fn4+".in"))
print ("<br> Downlaod the <a href=\"files/%s\" download=\"%s\">%s</a>" % (fn4+".out", fn4+".out", fn4+".out"))
print ("<br> Downlaod the <a href=\"files/%s\" download=\"%s\">%s</a>" % (fn4+".Xsec.txt", fn4+".Xsec.txt", fn4+".Xec.txt"))
if pngName != "" :
print ("<img src=\"files/%s\">" % pngName)
@ -156,6 +180,7 @@ 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>DWBA.in File : %s" % message4a)
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>" % dwba_2)

View File

@ -125,6 +125,10 @@
<td style="text-align:right" width="200">DWBA File ^ </th>
<td><input type = "file" name = "filename4" /> </td>
</tr>
<tr>
<td style="text-align:right" width="200">DWBA.in File ^ </th>
<td><input type = "file" name = "filename4a" /> </td>
</tr>
<tr>
<td style="text-align:right" width="200">Plot Config File * </th>
<td><input type = "file" name = "filename5" /> </td>