def main(result_file): """ Appends the last execution time of a makefile to ``result_file`` Please make sure the execution actually ended before running this """ with open(result_file, 'a+') as stream: duration = float(RED.get(END_TIME)) - float(RED.get(START_TIME)) stream.write(str(duration) + "\n")
def main(): """ Runs a makefile on several nodes """ # Flush the database, from one execution to another RED.flushdb() # The makefile to use in case none is provided default_makefile = None for makefile in ("GNU-makefile", "makefile", "Makefile"): if exists(makefile): default_makefile = makefile # Parse the args from the command line parser = ArgumentParser(description="Distributed make") parser.add_argument( "-f", "--file", nargs="?", dest="makefile", default=default_makefile, type=FileType("r"), help="the file to use" ) parser.add_argument("-a", "--async", action="store_true", help="do not wait for tasks completion") parser.add_argument("target", nargs="?", default="", help="the makefile's target to create") args = parser.parse_args() if args.makefile is None: print "No makefile was found. Stopping." return # Initialize the start_time and the end_time (for the measures) RED.set(START_TIME, time()) RED.set(END_TIME, time()) # Parse the makefile makefile_parser = Parser() makefile_parser.parse_makefile(args.makefile) # Fetch the target task = makefile_parser.get_task(args.target) # Create a dependency tree and launch all the leaves # in parrallel dep_tree = DepTree(task) RED.set(TASK_NUM, dep_tree.nodes_num) group((run_task.s(leaf) for leaf in dep_tree.leaves))() if not args.async: # Wait for the last task to return RED.blpop(END_LIST)