Пример #1
0
def handle_post():
    batch_id = BATCHPROFILER_DEFAULTS[BATCH_ID]
    my_batch = RunBatch.BPBatch()
    my_batch.select(batch_id)
    txt_output_dir = RunBatch.text_file_directory(my_batch)
    job_script_dir = RunBatch.script_file_directory(my_batch)
    what_i_did = {}
    maybe_chmod(txt_output_dir, 0777, what_i_did)
    maybe_chmod(job_script_dir, 0777, what_i_did)

    for run in my_batch.select_runs():
        for path in [
                RunBatch.run_text_file_path(my_batch, run),
                RunBatch.run_out_file_path(my_batch, run),
                RunBatch.run_err_file_path(my_batch, run)
        ]:
            maybe_chmod(path, 0644, what_i_did)

    print "Content-Type: application/json"
    print
    print json.dumps(what_i_did)
import os.path
import subprocess

import sql_jobs

#
# TODO: Move the logic that collects the load statements into sql_jobs
#
# TODO: use yattag to build the HTML
#

batch_id = BATCHPROFILER_VARIABLES[BATCH_ID]
sql_script = BATCHPROFILER_VARIABLES[SQL_SCRIPT]
output_file = BATCHPROFILER_VARIABLES[OUTPUT_FILE]
queue = BATCHPROFILER_VARIABLES[QUEUE]
my_batch = RunBatch.BPBatch()
my_batch.select(batch_id)

re_load_line = re.compile(
    "'(.+?)[0-9]+_[0-9]+_(Image|Object).CSV'\sREPLACE\sINTO\sTABLE\s([A-Za-z0-9_]+)\s"
)
re_ignore_line = re.compile("SHOW WARNINGS;")
table_lines = []
image_prefix = None
object_prefix = None
sql_script_file = open(my_batch.data_dir + os.sep + sql_script, "r")
in_table_defs = True
try:
    for line in sql_script_file:
        match = re_load_line.search(line)
        if match: