Пример #1
0
 def build_submit_run(self):
     title = "Batch # %d resubmitted"%(self.my_batch.batch_id)
     with self.tag("html"):
         with self.tag("head"):
             with self.tag("title"):
                 self.text(title)
             with self.tag("style"):
                 self.doc.asis(StyleSheet.BATCHPROFILER_STYLE)
         with self.tag("body"):
             with self.tag("h1"):
                 self.text(title)
             with self.tag("div"):
                 self.text("Your batch # %d has been resubmitted." %
                           self.my_batch.batch_id)
             with self.tag("table", klass="run-table"):
                 with self.tag("tr"):
                     with self.tag("th"):
                         self.text("First")
                     with self.tag("th"):
                         self.text("Last")
                     with self.tag("th"):
                         self.text("Job #")
                 kwds = {}
                 run_id = BATCHPROFILER_VARIABLES[RUN_ID]
                 submit_run = BATCHPROFILER_VARIABLES[SUBMIT_RUN]
                 if submit_run == RESUBMIT:
                     submit_run = None
                 if run_id is not None:
                     kwds["by_run"] = run_id
                 if submit_run == RunBatch.JS_INCOMPLETE:
                     kwds["by_status"] = RunBatch.INCOMPLETE_STATUSES
                 elif submit_run in RunBatch.INCOMPLETE_STATUSES:
                     kwds["by_status"] = [submit_run]
                 jobs = self.my_batch.select_jobs(**kwds)
                 for run, job, status in jobs:
                     assert isinstance(run, RunBatch.BPRun)
                     assert isinstance(job, RunBatch.BPJob)
                     if run.run_id == self.run_id or \
                        (submit_run == RunBatch.JS_INCOMPLETE and
                         status in RunBatch.INCOMPLETE_STATUSES) or \
                        status == submit_run or \
                        submit_run == RunBatch.JS_ALL:
                         new_job = RunBatch.run_one(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(new_job.job_id))
Пример #2
0
def run_sql_file(batch_id, sql_filename):
    """Use the mysql command line to run the given SQL script
    
    batch_id    - sql_file is associated with this batch
    sql_path    - path and file of the sql script
    queue       - run job on this queue
    email       - who to email when done
    returns the RunBatch.BPJob
    """
    cwd = os.path.dirname(__file__)
    batch = RunBatch.BPBatch()
    batch.select(batch_id)
    run = RunBatch.BPSQLRun.select_by_sql_filename(batch, sql_filename)
    if run is None:
        sql_path = os.path.join(RunBatch.batch_script_directory(batch),
                                sql_filename)
        cmd = "%s -b %d -i %s"%(os.path.join(cwd, "sql_jobs.py"),
                                batch_id, sql_path)
        run = RunBatch.BPSQLRun.create(batch, sql_filename, cmd)
    return RunBatch.run_one(batch, run, cwd=cwd)