def get_filelist(cnffile_source): list = [] if os.path.isdir(cnffile_source): print("Directory source found. Scanning for .cnf files ...") #os.chdir(cnffile_source) for (dpath, dnames, filenames) in os.walk(cnffile_source): #print(dpath) for f in filenames: #print(f + ": " + repr(os.path.isfile(dpath + f))) if os.path.isfile(dpath + "/" + f) and f.split(".")[len(f.split(".")) - 1] == "cnf": list.append(dpath + "/" + f) else: print("A file with a list of cnf files found.") list = read_filelist(cnffile_source) print("DONE") return list
f.write("<tbody>") for p in list: stringtime1 = '--' if p[1] >= TIMEOUT else repr(round(p[1], 3)) stringtime2 = '--' if p[2] >= TIMEOUT else repr(round(p[2], 3)) f.write("<tr>") onesmaller = p[1] < p[2] f.write("<td>" + p[0] + "</td><td>" + bold(stringtime1, onesmaller) + "</td><td>" + bold(stringtime2, not onesmaller) + "</td>") f.write("</tr>") f.write("</tbody>") f.write("</table>") f.write("</body>\n</html>") if len(sys.argv) < 3: print("Usage:") print("\t /comparetimes.py LIST_FILE BINARY1 BINARY2") print("\t /comparetimes.py DIRECTORY BINARY1 BINARY2") exit(0) PATH_TO_SHARPSAT_BINARY1 = os.path.expandvars(os.path.expanduser(sys.argv[2])) PATH_TO_SHARPSAT_BINARY2 = os.path.expandvars(os.path.expanduser(sys.argv[3])) cnflist = read_filelist(os.path.expandvars(os.path.expanduser(sys.argv[1]))) compare_data = run_all_on_list(TIMEOUT, cnflist, [PATH_TO_SHARPSAT_BINARY1, PATH_TO_SHARPSAT_BINARY2]) store_results("compare_results.html", PATH_TO_SHARPSAT_BINARY1, PATH_TO_SHARPSAT_BINARY2, compare_data)
for p in list: stringtime1 = '--' if p[1] >= TIMEOUT else repr(round(p[1], 3)) stringtime2 = '--' if p[2] >= TIMEOUT else repr(round(p[2], 3)) f.write("<tr>") onesmaller = p[1] < p[2] f.write("<td>" + p[0] + "</td><td>" + bold(stringtime1, onesmaller) + "</td><td>" + bold(stringtime2, not onesmaller) + "</td>") f.write("</tr>") f.write("</tbody>") f.write("</table>") f.write("</body>\n</html>") if len(sys.argv) < 3: print("Usage:") print("\t /comparetimes.py LIST_FILE BINARY1 BINARY2") print("\t /comparetimes.py DIRECTORY BINARY1 BINARY2") exit(0) PATH_TO_SHARPSAT_BINARY1 = os.path.expandvars(os.path.expanduser(sys.argv[2])) PATH_TO_SHARPSAT_BINARY2 = os.path.expandvars(os.path.expanduser(sys.argv[3])) cnflist = read_filelist(os.path.expandvars(os.path.expanduser(sys.argv[1]))) compare_data = run_all_on_list( TIMEOUT, cnflist, [PATH_TO_SHARPSAT_BINARY1, PATH_TO_SHARPSAT_BINARY2]) store_results("compare_results.html", PATH_TO_SHARPSAT_BINARY1, PATH_TO_SHARPSAT_BINARY2, compare_data)