Пример #1
0
import StyleSheet
import cgi
import os
import os.path

def remove_if_exists(path):
    if os.path.exists(path):
        os.remove(path)

form = cgi.FieldStorage()
delete_action = form["delete_action"].value
if form.has_key("run_id"):
    run_id = int(form["run_id"].value)
    my_batch,my_run = RunBatch.LoadRun(run_id)
    if ((delete_action.upper() == "ALL") or (delete_action.upper() == "TEXT")):
        remove_if_exists(RunBatch.RunTextFilePath(my_batch, my_run))

    if (delete_action.upper() == "ALL") or (delete_action.upper() == "OUTPUT"):
        remove_if_exists(RunBatch.RunOutFilePath(my_batch, my_run))

    if (delete_action.upper() == "ALL") or (delete_action.upper() == "DONE"):
        remove_if_exists(RunBatch.RunDoneFilePath(my_batch, my_run))
elif form.has_key("batch_id"):
    batch_id = int(form["batch_id"].value)
    my_batch = RunBatch.LoadBatch(batch_id)
    for my_run in my_batch["runs"]:
        if ((delete_action.upper() == "ALL") or (delete_action.upper() == "TEXT")):
            remove_if_exists(RunBatch.RunTextFilePath(my_batch, my_run))

        if (delete_action.upper() == "ALL") or (delete_action.upper() == "OUTPUT"):
            remove_if_exists(RunBatch.RunOutFilePath(my_batch, my_run))
Пример #2
0
                      onclick='return confirm("Do you really want to delete all done files for this batch?")'/>
 <input type='submit' 
                      name='delete_action' 
                      value='All'   
                      title='Delete all files for this batch' 
                      onclick='return confirm("Do you really want to delete all files for this batch?")'/>
 </form>
 </div>""" % (my_batch)
 print "</div></th>"
 print "</tr></thead>"
 print "<tbody>"
 for run in my_batch["runs"]:
     x = my_batch.copy()
     x.update(run)
     x["text_file"] = RunBatch.RunTextFile(run)
     x["text_path"] = RunBatch.RunTextFilePath(my_batch, run)
     x["done_file"] = RunBatch.RunDoneFile(run)
     x["done_path"] = RunBatch.RunDoneFilePath(my_batch, run)
     x["out_file"] = RunBatch.RunOutFile(run)
     x["out_path"] = RunBatch.RunOutFilePath(my_batch, run)
     print "<tr>"
     print "<td>%(start)d</td><td>%(end)d</td><td>%(job_id)s</td>" % (x)
     if run["status"] == "Complete":
         cpu = RunBatch.GetCPUTime(my_batch, run)
         print "<td style='color:green'>"
         if cpu:
             print "Complete (%.2f sec)" % (cpu)
         else:
             print "Complete"
         stat = "Complete"
         print "</td>"
Пример #3
0
import cgi
import os

form = cgi.FieldStorage()
batch_id = int(form["batch_id"].value)
my_batch = RunBatch.LoadBatch(batch_id)
status_dir = "%(data_dir)s/status/" % (my_batch)
txt_output_dir = "%(data_dir)s/txt_output/" % (my_batch)
if os.path.exists(status_dir):
    os.chmod(status_dir, 0777)
if os.path.exists(txt_output_dir):
    os.chmod(txt_output_dir, 0777)

for run in my_batch["runs"]:
    for path in [
            RunBatch.RunTextFilePath(my_batch, run),
            RunBatch.RunDoneFilePath(my_batch, run),
            RunBatch.RunOutFilePath(my_batch, run)
    ]:
        if os.path.exists(path):
            os.chmod(path, 0644)

url = "ViewBatch.py?batch_id=%(batch_id)d" % (my_batch)
print "Content-Type: text/html"
print
print "<html><head>"
print "<meta http-equiv='refresh' content='0; URL=%(url)s' />" % (globals())
print "</head>"
print "<body>This page should be redirected to <a href='%(url)s'/>%(url)s</a></body>" % (
    globals())
print "</html>"
Пример #4
0
"""
#
# View the text file that is produced by bsub during batch processing
#
import cgitb

cgitb.enable()
import RunBatch
import cgi
import os
import os.path
import stat

if cgi.FieldStorage().has_key("run_id"):
    run_id = int(cgi.FieldStorage()["run_id"].value)
    my_batch, my_run = RunBatch.LoadRun(run_id)
    text_file_path = RunBatch.RunTextFilePath(my_batch, my_run)
else:
    text_file_path = cgi.FieldStorage()["file_name"].value
#
# This is a temporary work-around because files get created
# with the wrong permissions
#
if (os.stat(text_file_path)[0] & stat.S_IREAD) == 0:
    os.chmod(text_file_path, 0644)
text_file = open(text_file_path, "r")
print "Content-Type: text/plain"
print
print text_file.read()
text_file.close()
Пример #5
0
cgitb.enable()
import RunBatch
import cgi
import os

form = cgi.FieldStorage()
batch_id = int(form["batch_id"].value)
my_batch = RunBatch.LoadBatch(batch_id)
status_dir = "%(data_dir)s/status/"%(my_batch)
txt_output_dir = "%(data_dir)s/txt_output/"%(my_batch)
if os.path.exists(status_dir):
    os.chmod(status_dir,0777)
if os.path.exists(txt_output_dir):
    os.chmod(txt_output_dir,0777)
    
for run in my_batch["runs"]:
    for path in [RunBatch.RunTextFilePath(my_batch,run),
                 RunBatch.RunDoneFilePath(my_batch,run),
                 RunBatch.RunOutFilePath(my_batch,run)]:
        if os.path.exists(path):
            os.chmod(path,0644)

url = "ViewBatch.py?batch_id=%(batch_id)d"%(my_batch)
print "Content-Type: text/html"
print
print "<html><head>"
print "<meta http-equiv='refresh' content='0; URL=%(url)s' />"%(globals())
print "</head>"
print "<body>This page should be redirected to <a href='%(url)s'/>%(url)s</a></body>"%(globals())
print "</html>"