def test_all_samples_in_sample_server(): screen = CM.Screen() print("Testing all samples in the sample server") f = open("/root/Documents/paths.txt", "r") paths = f.readlines() print(paths) PromptUtils(screen).enter_to_continue()
def sync(prompt=True): clearDir('../data/s3') run([ "aws", "s3", "sync", "s3://atlascampi", "../data/s3", "--only-show-errors" ]) if prompt: PromptUtils(screen).enter_to_continue()
def minimal_addition_minimum_flow(file): try: result = algo.minimal_addition_minimum_flow(file) for index, res in enumerate(result): table_print("D{}".format(index + 1), res) except Exception as e: Screen().println("\nError: %s\n" % e) finally: PromptUtils(Screen()).enter_to_continue()
def action(color_name): text = """ Dark spruce forest frowned on either side of the frozen waterway. The trees had been stripped by a recent wind of their white covering of frost, and they seemed to lean toward each other, black and ominous, in the fading light. A vast silence reigned over the land. """ print(color(text, fg=color_name)) PromptUtils(Screen()).enter_to_continue()
def floyd(file): try: result = algo.floyd(file) for key, value in result.items(): table_print(key, value) # print(fl.floyd(file)) except Exception as e: Screen().println("\nError: %s\n" % e) finally: PromptUtils(Screen()).enter_to_continue()
def test_sample_on_network(sample): # Find a random IP to execute the sample on # TODO: Fetch the ips automatically from the connected list x = randrange(3) # ip = config.machineIPs[x] # ip = '10.0.0.3' ip = '127.0.0.1' print("Random IP: " + ip) sm.sampleAtOrigin(ip, sample, incubation_time) screen = CM.Screen() PromptUtils(screen).enter_to_continue()
def best_neighbour(file): start = Screen().input(prompt="Zadaj startovaci vrchol: ") start_index = string.ascii_uppercase.index(start.upper()) result = algo.best_neighbour(file, start_index) table_print("", result[1]) path = [string.ascii_uppercase[node] for node, weight in result[0]] weights = [weight for nodes, weight in result[0]] print("->".join(path) + "->{}".format(start.upper())) print(" + ".join(map(str, weights)) + "= {}".format(sum(weights))) PromptUtils(Screen()).enter_to_continue()
def prim(file): result = algo.prim(file) edges = [] weights = [] for edge, weight in result: v1 = string.ascii_uppercase[edge[0]] v2 = string.ascii_uppercase[edge[1]] edge = v1 + "->" + v2 edges.append(edge) weights.append(weight) print(" , ".join(edges)) print(" + ".join(map(str, weights)) + " = {}".format(sum(weights))) PromptUtils(Screen()).enter_to_continue()
def cpm_table(file): data = cpm.copm_cpm(algo.get_tasks(file)) table = BeautifulTable() table.set_style(BeautifulTable.STYLE_BOX) # create table headers col_headers = ["Cinnost", "ZM", "KM", "ZP", "KP", "RC", "Kriticka"] # Set column headers table.column_headers = col_headers for row in data: table.append_row(row) print(table) PromptUtils(Screen()).enter_to_continue()
def pert_table(file): data, standard_deviation = algo.pert(file) table = BeautifulTable() table.set_style(BeautifulTable.STYLE_BOX) # create table headers col_headers = [ "Cinnost", "Zavislosti", "aij", "mij", "bij", "trvanie", "odchylka", "rozptyl" ] # Set column headers table.column_headers = col_headers for row in data: table.append_row(row) print(table) print("Smerodajna odchylka trvanie projektu q(Te)= {}".format( standard_deviation)) PromptUtils(Screen()).enter_to_continue()
def create_graph(file): dist_matrix = algo.get_matrix(file) dist_matrix = np.where(dist_matrix == "M", 0, dist_matrix).astype(np.int) graph = nx.Graph() letters = string.ascii_uppercase nodes = [letters[x] for x in range(dist_matrix.shape[0])] graph.add_nodes_from(nodes) edges = [] for x in range(dist_matrix.shape[0]): for y in range(dist_matrix.shape[1]): if dist_matrix[x][y] != 0: edges.append( [letters[x], letters[y], { 'weight': dist_matrix[x][y] }]) graph.add_edges_from(edges) # planar layout works well so far # pos = nx.spring_layout(graph, seed=42) pos = nx.planar_layout(graph) nx.draw(graph, pos) labels = nx.get_edge_attributes(graph, 'weight') nx.draw_networkx_edge_labels(graph, pos, edge_labels=labels) # nx.draw_networkx_labels(graph, pos, font_size=20, font_family="sans-serif") nx.draw_networkx_labels(graph, pos) graph_path = pathlib.Path(folder, "graph.png") fig = plt.savefig(graph_path) plt.show() plt.close(fig) # open file with default image program # os.startfile(graph_path) PromptUtils(Screen()).enter_to_continue()
def best_neighbour_matrix(file): result = algo.best_neighbour_matrix(file) table_print("E", result) PromptUtils(Screen()).enter_to_continue()
def minimal_addition(file): result = algo.minimal_addition(file) for index, res in enumerate(result): table_print("D{}".format(index + 1), res) PromptUtils(Screen()).enter_to_continue()
def cleanLocal(): os.system("rm -rf ../data/s3/*") PromptUtils(screen).enter_to_continue()