diff --git a/bfs/scripts/log.txt b/bfs/scripts/log.txt deleted file mode 100644 index 891a4c6..0000000 --- a/bfs/scripts/log.txt +++ /dev/null @@ -1,12 +0,0 @@ -Could not acquire mutex to add new client thread -Listening for clients... -Could not acquire mutex to add new client thread -Listening for clients... -Hello new client! -Listening for clients... -Could not acquire mutex to add new client thread -Listening for clients... -Hello new client! -Listening for clients... -Hello new client! -Listening for clients... diff --git a/bfs/scripts/startbfs.py b/bfs/scripts/startbfs.py index 6c4ad4d..840d53a 100644 --- a/bfs/scripts/startbfs.py +++ b/bfs/scripts/startbfs.py @@ -1,13 +1,16 @@ import os -import multiprocessing as mp +import argparse import subprocess +import multiprocessing as mp + +os.chdir(os.path.dirname(__file__)) def start_program(program): if not isinstance(program, str): raise ValueError("Argument passed to start_program_sync() should be a string") - return os.system("cmd /c " + program) + return os.system("START /wait \""+ program +"\" CMD /c " + program) def start_program_async(program): @@ -19,11 +22,52 @@ def start_program_async(program): return p +def flatten_list(lst): + flat = [] + for l in lst: + if isinstance(l, list): + flat.extend(flatten_list(l)) + else: + flat.append(l) + return flat + + +def get_exe_names(algo_args, io_proc_args, config_file): + names = [] + + if algo_args is not None: + names.append(algo_args) + + if io_proc_args is not None: + names.extend(flatten_list(io_proc_args)) + + return names + + def main(): - a = start_program_async("..\\bin\\AlgoBreadcrumbs.exe") - io = start_program_async("..\\bin\\VirtualOutputIOProcessor.exe") - a.join() - io.join() + parser = argparse.ArgumentParser() + parser.add_argument("-a", "--algorithm", default=None, + help="""Specify the name of the algorithm .exe file to run in a separate process. Specifying +an algorithm like this eliminates the ability for the user to specify a specify configuration for this algorithm. +the created algorithm process will use the configuration file located in it's default config directory.""") + parser.add_argument("-p", "--io_processor", action='append', nargs='+', default=None, + help="""Specify the name of the IO Processor .exe file to run in a separate process. Specifying +an IO Processor like this eliminates the ability for the user to specify a specify configuration for this IO Processor. +the created IO Processor process will use the configuration file located in it's default config directory.""") + parser.add_argument("-c", "--config", default=None, + help="""Specify the configuration file to use. This can specify the algorithm and IO +processors to run. It can also specify settings for the individual IO Processors and algorithm themselves. The +config file will be divided up into smaller config files (one for each process run) that the respective processes +will read and adjust their settings accordingly. That way, each process only has access to their own config settings. +Note: this can be used in conjunction with -a and -p, but care is necessary to not produce any duplicate proceses.""") + args = parser.parse_args() + + binary_path = os.path.abspath("..\\bin") + exe_ending = ".exe" + exe_names = get_exe_names(args.algorithm, args.io_processor, args.config) + procs = [start_program_async(os.path.join(binary_path, x) + exe_ending) for x in exe_names] + [proc.join() for proc in procs] + print("DONE")