Exemplo n.º 1
0
def pc_log(conf, top_dt, end_dt, dur, area, dump = True):
    
    _logger.info("job start ({0} - {1} in {2})".format(top_dt, end_dt, area))
    
    edict, evmap = get_edict(conf, top_dt, end_dt, dur, area)

    _logger.info("{0} events found in given term of log data".format(
            len(edict)))
    if dump:
        tempfn = thread_name(conf, top_dt, end_dt, dur, area) + ".temp"
        with open(tempfn, 'w') as f:
            pickle.dump((edict, evmap), f)

    if len(edict) > 2:
        threshold = conf.getfloat("dag", "threshold")
        ci_func = conf.get("dag", "ci_func")
        binarize = pc_input.input_binarize(ci_func)
        data = log2event.event2stat(edict, top_dt, end_dt, dur, binarize)
        graph = pc_input.pc(data, threshold, ci_func)
    else:
        _logger.info("insufficient events({0}), return empty dag".format(\
                len(edict)))
        graph = pcresult.empty_dag()

    output = pcresult.PCOutput(conf)
    output.make(graph, evmap, top_dt, end_dt, dur, area)
    if dump:
        output.dump()
        common.rm(tempfn)

    _logger.info("job done, output {0}".format(output.filename))
    return output
Exemplo n.º 2
0
def remove_flag_8():
    filenames_dict = common.get_flag_8_filenames()
    files_to_remove = filenames_dict['all_files']

    for filepath in files_to_remove:
        common.rm(filepath)

    common.rmdir(common.FLAG_8_DIRECTORY)
Exemplo n.º 3
0
 def run(self):
     extensions = os.listdir(common.extensions_folder)
     for extension in extensions:
         newext = os.path.join(common.extensions_folder, extension)
         oldext = os.path.join(settings.extensions_folder, extension)
         if os.path.isfile(oldext):
             common.rm(oldext)
         elif os.path.isdir(oldext):
             common.rmr(oldext)
         if os.path.isfile(newext):
             common.cp(newext, oldext)
         else:
             common.cpr(newext, oldext)
Exemplo n.º 4
0
 def run(self):
     extensions = os.listdir(common.extensions_folder)
     for extension in extensions:
         newext = os.path.join(common.extensions_folder, extension)
         oldext = os.path.join(settings.extensions_folder, extension)
         if os.path.isfile(oldext):
             common.rm(oldext)
         elif os.path.isdir(oldext):
             common.rmr(oldext)
         if os.path.isfile(newext):
             common.cp(newext, oldext)
         else:
             common.cpr(newext, oldext)
Exemplo n.º 5
0
def remove_flag_25():
    common.rm(common.FLAG_25_PROCESS_SCRIPT)
    common.rm(common.FLAG_25_SCRIPT)

    # Kill any and all processes started by the flag 25 script
    all_processes = subprocess.check_output(['ps', 'aux']).strip().split('\n')
    bill_process_pattern = re.compile("^.*/bin/sh /tmp/bill.sh$")
    bill_process_lines = [
        process_info for process_info in all_processes
        if bill_process_pattern.match(process_info)
    ]
    bill_pids = [line.split()[1] for line in bill_process_lines]
    [subprocess.check_output(['kill', pid]) for pid in bill_pids]
Exemplo n.º 6
0
def remove_flag_15():
    common.rm(common.FLAG_FILE_15)
    common.rm(common.FLAG_FILE_15_COMPRESSED)
Exemplo n.º 7
0
def remove_flag_14():
    common.rm(common.get_script_path(14))
Exemplo n.º 8
0
def remove_flag_13():
    common.rm(common.get_script_path(13))
    common.rm(common.FLAG_13_THING_1)
    common.rm(common.FLAG_13_THING_2)
Exemplo n.º 9
0
def remove_flag_12():
    common.rm(common.get_script_path(12))
    common.rmdir(common.FLAG_12_DIRECTORY)
Exemplo n.º 10
0
                  type="string",
                  default=config.DEFAULT_CONFIG_NAME,
                  help="configuration file path")
    op.add_option("-d",
                  "--delete",
                  action="store_true",
                  dest="delete",
                  default=False,
                  help="clean edge_filter dump file and reconstruct")

    (options, args) = op.parse_args()

    conf = config.open_config(options.conf)
    if options.delete:
        filename = conf.get("visual", "edge_filter_file")
        common.rm(filename)
    #test_edge_filter(conf)
    if len(args) == 0:
        sys.exit("give me mode name")
    mode = args.pop(0)
    if mode == "list":
        test_edge_filter(conf)
        #test_edge_filter_cont(conf)
    elif mode == "show-count":
        show_count(conf, mode="count")
    elif mode == "show-count-ighost":
        if len(args) > 0:
            th = float(args[0])
            show_count(conf, threshold=th, mode="count-ighost")
        else:
            show_count(conf, mode="count-ighost")
Exemplo n.º 11
0
def remove_flag_2():
    common.rm(common.FLAG_FILE_2)
Exemplo n.º 12
0
def remove_flag_17():
    common.rm(common.get_script_path(17))
    common.rm(common.FLAG_FILE_17_INPUT_FILE)
Exemplo n.º 13
0
def remove_flag_6():
    common.rm(common.FLAG_FILE_6)
Exemplo n.º 14
0
def remove_flag_7():
    common.rm(common.FLAG_FILE_7)
Exemplo n.º 15
0
def remove_flag_5():
    common.rm(common.FLAG_FILE_5)
Exemplo n.º 16
0
def remove_flag_4():
    common.rm(common.FLAG_4_LINK_NAME)
    common.rm(common.FLAG_FILE_4)
Exemplo n.º 17
0
def remove_flag_3():
    common.rm(common.FLAG_FILE_3)
Exemplo n.º 18
0
def remove_flag_1():
    common.rm(common.FLAG_FILE_1)
Exemplo n.º 19
0
    conf.set("visual", "edge_filter_th", "2.0")
    l_result = pcresult.results(conf)
    ef = EdgeFilter(conf)
    ef.show_all(l_result)


if __name__ == "__main__":
    usage = "usage: {0} [options]".format(sys.argv[0])
    import optparse
    op = optparse.OptionParser(usage)
    op.add_option("-c", "--config", action="store",
            dest="conf", type="string", default=config.DEFAULT_CONFIG_NAME,
            help="configuration file path")
    op.add_option("-d", "--delete", action="store_true",
            dest="delete", default=False,
            help="clean edge_filter dump file and reconstruct")
    
    (options, args) = op.parse_args()

    conf = config.open_config(options.conf)
    if options.delete:
        filename = conf.get("visual", "edge_filter_file")
        common.rm(filename)
    #test_edge_filter(conf)
    test_edge_filter_cont(conf)





Exemplo n.º 20
0
def remove_flag_16():
    common.rm(common.get_script_path(16))
Exemplo n.º 21
0
    common.rm(common.get_script_path(24))


def remove_flag_25():
    common.rm(common.FLAG_25_PROCESS_SCRIPT)
    common.rm(common.FLAG_25_SCRIPT)

    # Kill any and all processes started by the flag 25 script
    all_processes = subprocess.check_output(['ps', 'aux']).strip().split('\n')
    bill_process_pattern = re.compile("^.*/bin/sh /tmp/bill.sh$")
    bill_process_lines = [
        process_info for process_info in all_processes
        if bill_process_pattern.match(process_info)
    ]
    bill_pids = [line.split()[1] for line in bill_process_lines]
    [subprocess.check_output(['kill', pid]) for pid in bill_pids]


###
### Begin script execution
###

common.quit_if_not_root()

cleaning_functions = filter(lambda x: x.startswith("remove_flag_"), locals())

for func_name in cleaning_functions:
    locals()[func_name]()

common.rm(common.HINTS_FILE)
Exemplo n.º 22
0
def remove_flag_23():
    common.rm(common.get_script_path(23))
Exemplo n.º 23
0
def remove_flag_11():
    common.rm(common.get_script_path(11))
    common.rm(common.FLAG_11_BOULDER)
Exemplo n.º 24
0
def remove_flag_9():
    common.rm(common.FLAG_FILE_9)
Exemplo n.º 25
0
def remove_flag_24():
    common.rm(common.get_script_path(24))
Exemplo n.º 26
0
def remove_flag_10():
    common.rm(common.FLAG_FILE_10_ORIGINAL_PATH)
    common.rm(common.FLAG_FILE_10_DESIRED_PATH)
    common.rm(common.get_script_path(10))
    common.rmdir(common.FLAG_10_DIRECTORY)
Exemplo n.º 27
0
def stage_flag_15():
    common.write_to_file(common.FLAG_FILE_15, get_formatted_flag_line(15))
    subprocess.check_output(['tar', '-czvf', common.FLAG_FILE_15_COMPRESSED_NAME, common.FLAG_FILE_15_NAME], cwd=common.USER_HOME_DIR)
    common.rm(common.FLAG_FILE_15)