def test_to_svg_file_name(self): chart1 = leather.Chart() chart1.add_dots(self.data1) chart2 = leather.Chart() chart2.add_dots(self.data2) grid = leather.Grid() grid.add_many([chart1, chart2, chart1]) grid.to_svg('.test.svg') self.assertTrue(os.path.exists(TEST_SVG))
def test_to_svg_file_handle(self): chart1 = leather.Chart() chart1.add_dots(self.data1) chart2 = leather.Chart() chart2.add_dots(self.data2) grid = leather.Grid() grid.add_many([chart1, chart2, chart1]) with open('.test.svg', 'w') as f: grid.to_svg(f) self.assertTrue(os.path.exists(TEST_SVG))
def test_add_many(self): chart1 = leather.Chart() chart1.add_dots(self.data1) chart2 = leather.Chart() chart2.add_dots(self.data2) grid = leather.Grid() grid.add_many([chart1, chart2, chart1]) svg = self.render_chart(grid) self.assertElementCount(svg, '.axis', 6) self.assertElementCount(svg, '.series', 3) self.assertElementCount(svg, '.dots', 3) self.assertElementCount(svg, 'circle', 13)
def test_add_one(self): chart1 = leather.Chart() chart1.add_dots(self.data1) chart2 = leather.Chart() chart2.add_dots(self.data2) grid = leather.Grid() grid.add_one(chart1) grid.add_one(chart2) svg = self.render_chart(grid) self.assertElementCount(svg, '.axis', 4) self.assertElementCount(svg, '.series', 2) self.assertElementCount(svg, '.dots', 2) self.assertElementCount(svg, 'circle', 9)
import leather data1 = [ (0, 3), (4, 5), (7, 9), (8, 4) ] data2 = [ (3, 4), (5, 6), (7, 10), (8, 2) ] chart1 = leather.Chart('Dots') chart1.add_dots(data1) chart2 = leather.Chart('Lines') chart2.add_line(data2) grid = leather.Grid() grid.add_one(chart1) grid.add_one(chart2) grid.to_svg('examples/charts/grid.svg')
def main(): verbose = True out_dir = "" root = tkinter.Tk() root.withdraw() num_drives = input("How many drives would you like to process?\n>>> ") int_received = False while not int_received: try: num_drives = int(num_drives) int_received = True except ValueError: print("ERROR: You must enter an integer") num_drives = input( "How many drives would you like to process?\n>>> ") if num_drives <= 0: print("Too Few Drives") exit(0) lpo_drive_list = [] for drive_num in range(num_drives): txt_files_parsed = 0 html_files_parsed = 0 drive_name = input("What would you like to call drive #" + str(drive_num) + "?\n>>> ") lpo = LPOSeries() lpo.title = drive_name root.filename = filedialog.askopenfilenames( initialdir="C:\\Users\\Jake\\Desktop\\Projects\\Regression Testing", title=("Choose files for " + drive_name), filetypes=(('all files', '*.*'), )) # if we don't get a filename just bail if root.filename: infile_names = root.filename if out_dir == "": match = re.search('(.*)\.', infile_names[0]) dirs = match.group(1).split("/") dirs.pop() out_dir = '\\'.join(dirs) + "\\Processed" pathlib.Path(out_dir).mkdir(parents=True, exist_ok=True) else: exit(0) eztool_present = False sft_present = False for infile in infile_names: if infile[-4:] == ".txt": eztool_present = True text = read_file(infile, verbose) ezt_list = build_ezt_list(text, verbose) txt_files_parsed += 1 for ezt in ezt_list: lpo.add_ezt_cycle(ezt) elif infile[-4:] == "html": sft_present = True text = read_file(infile, verbose) sft_list = build_sft_list(text, verbose) html_files_parsed += 1 for sft in sft_list: lpo.add_sft_cycle(sft) if not eztool_present: ezt = EZTCycle("1", "1", "1") lpo.add_ezt_cycle(ezt) if not sft_present: sft = SFTCycle("1", "1", "1") message_string = (str(txt_files_parsed) + " EZTool files and " + str(html_files_parsed) + " SFT files were parsed for " + drive_name + "\n") if verbose: print(message_string) lpo_drive_list.append(lpo) for lpo in lpo_drive_list: lpo.generate_power_cycle_list() chart_list = [] for lpo in lpo_drive_list: power_cycle_file = out_dir + "\\" + lpo.title + "_AllCycles.txt" failing_cycle_file = out_dir + "\\" + lpo.title + "_ImportantCycles.txt" chart_file = out_dir + "\\" + lpo.title + "_Chart.svg" with open(power_cycle_file, "w") as f: f.write(PowerCycle.get_display_header()) for cycle in lpo.cycles: f.write(cycle.get_display_line()) with open(failing_cycle_file, "w") as f: f.write(PowerCycle.get_display_header()) for cycle in lpo.failed_cycles: f.write(cycle.get_display_line()) sft_data = lpo.get_sft_points() ezt_data = lpo.get_ezt_points() chart = leather.Chart(lpo.title) chart.add_dots(ezt_data, name="EZTool FWBootTime", radius=1.5) chart.add_dots(sft_data, name="SFT Detect Time", radius=1.5) x_axis = leather.Axis(name="Power Cycle") y_axis = leather.Axis(name="Detect Time in Seconds") chart.set_x_axis(x_axis) chart.set_y_axis(y_axis) chart.to_svg(chart_file, 500, 400) chart_list.append(chart) if len(chart_list) > 1: grid_file = out_dir + "\\" for lpo in lpo_drive_list: grid_file += lpo.title + "_" grid_file += "_Grid.svg" grid = leather.Grid() grid.add_many(chart_list) grid.to_svg(grid_file, 800, 600) max_file = out_dir + "\\" + "MaxPowerOnTimes.txt" max_text = "Max Times per Drive:\n" for lpo in lpo_drive_list: lpo.find_max_cycle() max_text += lpo.title + ": " + str(round(lpo.max_cycle.max_time(), 2)) + "\n" with open(max_file, "w") as f: f.write(max_text) if num_drives != 0: print("Processed Data stored in the directory:\n\n" + out_dir) else: print("You chose to process 0 drives, program exiting") Ju.wait()