Пример #1
0
 def build_text_file_table_cell(self, task):
     '''Build a table cell containing links to the stdout/err output'''
     bat = task.batch_array_task
     text_path = RunBatch.batch_array_task_text_file_path(bat)
     text_file = os.path.basename(text_path)
     err_path = RunBatch.batch_array_task_err_file_path(bat)
     err_file = os.path.basename(err_path)
     with self.tag("td", style="text-align: left"):
         for ft, path, filename in ((FT_TEXT_FILE, text_path, text_file),
                                    (FT_ERR_FILE, err_path, err_file)):
             with self.tag("div"):
                 if os.path.isfile(path):
                     with self.tag(
                             "a",
                             style="text-align: left",
                             href='ViewTextFile.py?%s=%d&%s=%d&%s=%s' %
                         (BATCH_ARRAY_ID, bat.batch_array.batch_array_id,
                          TASK_ID, bat.task_id, FILE_TYPE, ft),
                             title=path):
                         self.text(filename)
                 else:
                     with self.tag("span",
                                   style="text-align: left",
                                   title='Text file not available'):
                         self.text(filename)
Пример #2
0
 def build_text_file_table_cell(self, task):
     '''Build a table cell containing links to the stdout/err output'''
     bat = task.batch_array_task
     text_path = RunBatch.batch_array_task_text_file_path(bat)
     text_file = os.path.basename(text_path)
     err_path = RunBatch.batch_array_task_err_file_path(bat)
     err_file = os.path.basename(err_path)
     with self.tag("td", style="text-align: left"):
         for ft, path, filename in (
             (FT_TEXT_FILE, text_path, text_file),
             (FT_ERR_FILE, err_path, err_file)):
             with self.tag("div"):
                 if os.path.isfile(path):
                     with self.tag(
                         "a", style="text-align: left",
                         href='ViewTextFile.py?%s=%d&%s=%d&%s=%s' % 
                         (BATCH_ARRAY_ID, bat.batch_array.batch_array_id,
                          TASK_ID, bat.task_id, FILE_TYPE, ft),
                         title=path):
                         self.text(filename)
                 else:
                     with self.tag(
                         "span", 
                         style="text-align: left",
                         title='Text file not available'):
                         self.text(filename)
Пример #3
0
def delete_run(my_batch, my_run):
    if delete_action in (A_DELETE_ALL, A_DELETE_TEXT):
        for bat in RunBatch.BPBatchArrayTask.select_by_run(my_run):
            remove_if_exists(RunBatch.batch_array_task_text_file_path(bat))
            remove_if_exists(RunBatch.batch_array_task_err_file_path(bat))

    if delete_action in (A_DELETE_ALL, A_DELETE_OUTPUT):
        remove_if_exists(RunBatch.run_out_file_path(my_batch, my_run))
Пример #4
0
def delete_run(my_batch, my_run):
    if delete_action in (A_DELETE_ALL, A_DELETE_TEXT):
        for bat in RunBatch.BPBatchArrayTask.select_by_run(my_run):
            remove_if_exists(RunBatch.batch_array_task_text_file_path(bat))
            remove_if_exists(RunBatch.batch_array_task_err_file_path(bat))

    if delete_action in (A_DELETE_ALL, A_DELETE_OUTPUT):
        remove_if_exists(RunBatch.run_out_file_path(my_batch, my_run))
Пример #5
0
def do_it(batch_array_id, task_id):
    batch_array = RunBatch.BPBatchArray.select(batch_array_id)
    bat = RunBatch.BPBatchArrayTask.select_by_batch_array_and_task_id(
        batch_array, task_id)
    if bat is None:
        show_help()
        return
    run = bat.run
    my_batch = run.batch
    file_type = BATCHPROFILER_VARIABLES[FILE_TYPE]
    if file_type == FT_TEXT_FILE:
        show_file(RunBatch.batch_array_task_text_file_path(bat))
    elif file_type == FT_ERR_FILE:
        show_file(RunBatch.batch_array_task_err_file_path(bat))
    elif file_type == FT_OUT_FILE:
        download_attachment(RunBatch.run_out_file(my_batch, my_run),
                            RunBatch.run_out_file_path(my_batch, my_run))
    else:
        show_help("Unknown file type: %s" % file_type)
Пример #6
0
def do_it(batch_array_id, task_id):
    batch_array = RunBatch.BPBatchArray.select(batch_array_id)
    bat = RunBatch.BPBatchArrayTask.select_by_batch_array_and_task_id(
        batch_array, task_id)
    if bat is None:
        show_help()
        return
    run = bat.run
    my_batch = run.batch
    file_type = BATCHPROFILER_VARIABLES[FILE_TYPE]
    if file_type == FT_TEXT_FILE:
        show_file(RunBatch.batch_array_task_text_file_path(bat))
    elif file_type == FT_ERR_FILE:
        show_file(RunBatch.batch_array_task_err_file_path(bat))
    elif file_type == FT_OUT_FILE:
        download_attachment(
            RunBatch.run_out_file(my_batch, my_run),
            RunBatch.run_out_file_path(my_batch, my_run))
    else:
        show_help("Unknown file type: %s" % file_type)
Пример #7
0
 def build_job_table_body(self):
     with self.tag("tbody"):
         for task_status in self.tasks:
             assert isinstance(task_status, RunBatch.BPJobTaskStatus)
             task = task_status.job_task
             status = task_status.status
             assert isinstance(task, RunBatch.BPJobTask)
             run = task.batch_array_task.run
             assert isinstance(run, RunBatch.BPRun)
             job = task.job
             assert isinstance(job, RunBatch.BPJob)
             out_file = RunBatch.run_out_file(self.my_batch, run)
             out_path = RunBatch.run_out_file_path(self.my_batch, run)
             with self.tag("tr"):
                 with self.tag("td"):
                     self.text(str(run.bstart))
                 with self.tag("td"):
                     self.text(str(run.bend))
                 with self.tag("td"):
                     self.text(str(job.job_id))
                 with self.tag("td"):
                     self.text(str(task.batch_array_task.task_id))
                 if status == RunBatch.JS_DONE:
                     with self.tag("td"):
                         cpu = task_status.created - job.created
                         self.text("Complete (%.2f sec)" %
                                   (cpu.total_seconds()))
                 else:
                     with self.tag("td", style='color:red'):
                         with self.tag("div"):
                             self.text(status.lower().capitalize())
                         with self.tag("div"):
                             with self.tag("form",
                                           action="ViewBatch.py",
                                           method="POST",
                                           target="ResubmitWindow"):
                                 self.doc.input(type="hidden",
                                                name=BATCH_ID)
                                 self.doc.input(type="hidden",
                                                name=RUN_ID,
                                                value=str(run.run_id))
                                 self.doc.input(type="hidden",
                                                name=SUBMIT_RUN,
                                                value=RunBatch.JS_ONE)
                                 self.doc.stag("input",
                                               type='submit',
                                               name="Resubmit_Button",
                                               value=RESUBMIT)
                 self.build_text_file_table_cell(task)
                 if self.my_batch.wants_measurements_file:
                     with self.tag("td"):
                         if os.path.isfile(out_path):
                             with self.tag(
                                     "a",
                                     href='ViewTextFile.py?run_id=%d&%s=%s'
                                     % (run.run_id, FILE_TYPE, FT_OUT_FILE),
                                     title=out_path):
                                 self.text(out_file)
                         else:
                             with self.tag(
                                     "span",
                                     title='Output file not available'):
                                 self.text(out_file)
                 #
                 # This cell contains the form that deletes things
                 #
                 with self.tag("td"):
                     with self.tag("form",
                                   action='DeleteFile.py',
                                   method='POST'):
                         self.doc.input(type="hidden",
                                        name=RUN_ID,
                                        value=str(run.run_id))
                         text_file = os.path.basename(
                             RunBatch.batch_array_task_text_file_path(
                                 task.batch_array_task))
                         for action, filename in (
                             (A_DELETE_TEXT, text_file),
                             (A_DELETE_OUTPUT,
                              RunBatch.run_out_file(self.my_batch, run)),
                             (A_DELETE_ALL, "all files for this run")):
                             self.doc.stag(
                                 "input",
                                 type="submit",
                                 name=K_DELETE_ACTION,
                                 value=action,
                                 title='Delete file %s' % filename,
                                 onclick='return confirm("Do you really want'
                                 'to delete %s?")' % filename)
Пример #8
0
 def build_job_table_body(self):
     with self.tag("tbody"):
         for task_status in self.tasks:
             assert isinstance(task_status, RunBatch.BPJobTaskStatus)
             task = task_status.job_task
             status = task_status.status
             assert isinstance(task, RunBatch.BPJobTask)
             run = task.batch_array_task.run
             assert isinstance(run, RunBatch.BPRun)
             job = task.job
             assert isinstance(job, RunBatch.BPJob)
             out_file = RunBatch.run_out_file(self.my_batch, run)
             out_path = RunBatch.run_out_file_path(self.my_batch, run)
             with self.tag("tr"):
                 with self.tag("td"):
                     self.text(str(run.bstart))
                 with self.tag("td"):
                     self.text(str(run.bend))
                 with self.tag("td"):
                     self.text(str(job.job_id))
                 with self.tag("td"):
                     self.text(str(task.batch_array_task.task_id))
                 if status == RunBatch.JS_DONE:
                     with self.tag("td"):
                         cpu = task_status.created - job.created
                         self.text("Complete (%.2f sec)" %
                                   (cpu.total_seconds()))
                 else:
                     with self.tag("td", style='color:red'):
                         with self.tag("div"):
                             self.text(status.lower().capitalize())
                         with self.tag("div"):
                             with self.tag("form",
                                           action="ViewBatch.py",
                                           method="POST",
                                           target="ResubmitWindow"):
                                 self.doc.input(
                                     type="hidden", name=BATCH_ID)
                                 self.doc.input(
                                     type="hidden",
                                     name=RUN_ID,
                                     value=str(run.run_id))
                                 self.doc.input(
                                     type="hidden",
                                     name=SUBMIT_RUN,
                                     value=RunBatch.JS_ONE)
                                 self.doc.stag(
                                     "input",
                                     type='submit',
                                     name="Resubmit_Button",
                                     value=RESUBMIT)
                 self.build_text_file_table_cell(task)
                 if self.my_batch.wants_measurements_file:
                     with self.tag("td"):
                         if os.path.isfile(out_path):
                             with self.tag(
                                 "a", 
                                 href='ViewTextFile.py?run_id=%d&%s=%s' % 
                                 (run.run_id, FILE_TYPE, FT_OUT_FILE),
                                 title=out_path):
                                 self.text(out_file)
                         else:
                             with self.tag("span", 
                                      title='Output file not available'):
                                 self.text(out_file)
                 #
                 # This cell contains the form that deletes things
                 #
                 with self.tag("td"):
                     with self.tag("form", action='DeleteFile.py', method='POST'):
                         self.doc.input(
                             type="hidden", name=RUN_ID,
                             value = str(run.run_id))
                         text_file = os.path.basename(
                             RunBatch.batch_array_task_text_file_path(
                                 task.batch_array_task))
                         for action, filename in (
                             (A_DELETE_TEXT, text_file),
                             (A_DELETE_OUTPUT, RunBatch.run_out_file(self.my_batch, run)),
                             (A_DELETE_ALL, "all files for this run")):
                             self.doc.stag(
                                 "input",
                                 type="submit", name=K_DELETE_ACTION,
                                 value=action,
                                 title='Delete file %s' % filename, 
                                 onclick='return confirm("Do you really want'
                                 'to delete %s?")' % filename)