if "\\" in label or "." in label or "/" in label: label = label.replace("/", "\\") count = 0 fname = "" for filename in glob.glob(turk.log_root + "/*.out_file_loc"): if tools.my_read(filename).strip().replace("/", "\\") == label: fname = filename count += 1 if count > 1: print "Found more than one .out_file_loc file pointing to", label print "Exiting..." exit(0) if count == 0: print "Couldn't find any .out_file_loc file pointing to", label print "Maybe try absolute path" exit(0) label = fname[fname.rindex("\\") + 1:-13] print label trips = tools.remove_comments( tools.my_read(turk.log_root + "/" + label + ".trips").strip().split("\n")) trips = [i.split() for i in trips] trips = [(int(a), int(b), int(c)) for (a, b, c) in trips] #label=None turk.check_results( label, tools.my_read(turk.log_root + "/" + label + ".out_file_loc").strip(), trips)
if len(sys.argv) != 4 and len(sys.argv) != 3: print "Usage: runtrips.py config_file trips_file output_file" print " or" print "Usage: runtrips.py config_file trips_file" print "in which case the output file is trips_file.out" exit(1) if len(sys.argv) == 3: (a, b, c) = sys.argv[2].rpartition(".") if b == "": sys.argv.append(sys.argv[2] + ".out") else: sys.argv.append(a + ".out") print "outfile " + sys.argv[-1] config = tools.remove_comments(tools.my_read(sys.argv[1]).split("\n")) trips = tools.remove_comments(tools.my_read(sys.argv[2]).strip().split("\n")) db = config[0] payment = config[1] assert float(payment) < 0.9 #make sure we don't pay more than 90 cents/hit! height = config[2] comment = config[3] instructions = string.join(config[4:], "\n") if "%s" not in instructions: print "Instructions should have %s in them!" inst_shortcut = turk.shortcut_to_server(instructions) trips = [i.split() for i in trips] #print trips
if len(sys.argv)!=4 and len(sys.argv)!=3: print "Usage: runtrips.py config_file trips_file output_file" print " or" print "Usage: runtrips.py config_file trips_file" print "in which case the output file is trips_file.out" exit(1) if len(sys.argv)==3: (a,b,c) = sys.argv[2].rpartition(".") if b=="": sys.argv.append(sys.argv[2]+".out") else: sys.argv.append(a+".out") print "outfile "+sys.argv[-1] config = tools.remove_comments(tools.my_read(sys.argv[1]).split("\n")) trips = tools.remove_comments(tools.my_read(sys.argv[2]).strip().split("\n")) db = config[0] payment = config[1] assert float(payment)<0.9 #make sure we don't pay more than 90 cents/hit! height = config[2] comment = config[3] #see if line 4 has an integer try: reps = int(config[4]) instructions = string.join(config[5:],"\n") except: reps = 1 instructions = string.join(config[4:],"\n")
if "\\" in label or "." in label or "/" in label: label=label.replace("/","\\") count = 0 fname = "" for filename in glob.glob(turk.log_root+"/*.out_file_loc"): if tools.my_read(filename).strip().replace("/","\\")==label: fname = filename count += 1 if count>1: print "Found more than one .out_file_loc file pointing to",label print "Exiting..." exit(0) if count==0: print "Couldn't find any .out_file_loc file pointing to",label print "Maybe try absolute path" exit(0) label = fname[fname.rindex("\\")+1:-13] print label trips = tools.remove_comments(tools.my_read(turk.log_root+"/"+label+".trips").strip().split("\n")) trips = [i.split() for i in trips] trips = [(int(a),int(b),int(c)) for (a,b,c) in trips] #label=None turk.check_til_done(label,tools.my_read(turk.log_root+"/"+label+".out_file_loc").strip(),trips)