From cb30f0c63d796f8ccceb23c2527eca3f6a089263 Mon Sep 17 00:00:00 2001 From: Chris Palmer Date: Sat, 6 Feb 2021 10:39:39 +0000 Subject: [PATCH] Times for parts that no longer exist pruned from build times. Now shows changes to the total time. --- scripts/exports.py | 5 +++-- scripts/times.py | 41 ++++++++++++++++++++++++++--------------- scripts/views.py | 31 +++++++++++++++++++------------ 3 files changed, 48 insertions(+), 29 deletions(-) diff --git a/scripts/exports.py b/scripts/exports.py index 7b76574..0a46c70 100644 --- a/scripts/exports.py +++ b/scripts/exports.py @@ -72,10 +72,11 @@ def make_parts(target, part_type, parts = None): # # Decide which files to make # + all_parts = bom_to_parts(bom_dir, part_type) if parts: targets = list(parts) #copy the list so we dont modify the list passed in else: - targets = bom_to_parts(bom_dir, part_type) + targets = list(all_parts) for file in os.listdir(target_dir): if file.endswith('.' + part_type): if not file in targets: @@ -150,4 +151,4 @@ def make_parts(target, part_type, parts = None): for part in targets: print("Could not find a module called", part[:-4] + module_suffix, "to make", part) usage(part_type) - times.print_times() + times.print_times(all_parts) diff --git a/scripts/times.py b/scripts/times.py index 4eeedb3..f7b41fe 100644 --- a/scripts/times.py +++ b/scripts/times.py @@ -52,23 +52,34 @@ def add_time(name, start): del times[name.lower()] times[name] = round(time.time() - start, 3) -def print_times(): - write_times() +def print_times(files = None): sorted_times = sorted(times.items(), key=lambda kv: kv[1]) total = 0 + old_total = 0 for entry in sorted_times: - colour = Fore.WHITE key = entry[0] - new = entry[1] - delta = 0 - if key in last_times: - old = last_times[key] - delta = new - old - if delta > 0.3: - colour = Fore.RED - if delta < -0.3: - colour = Fore.GREEN - print(colour + "%5.1f %5.1f %s" % (new, delta, key)) - total += new + if files and not key in files: + del times[key] + else: + new = entry[1] + delta = 0 + colour = Fore.WHITE + if key in last_times: + old = last_times[key] + old_total += old + delta = new - old + if delta > 0.3: + colour = Fore.RED + if delta < -0.3: + colour = Fore.GREEN + print(colour + "%6.1f %5.1f %s" % (new, delta, key)) + total += new + write_times() if sorted_times: - print(Fore.WHITE + "%5.1f" % total) + colour = Fore.WHITE + delta = total - old_total + if delta > 1: + colour = Fore.RED + if delta < -1: + colour = Fore.GREEN + print(colour + "%6.1f %5.1f TOTAL%s" % (total, delta, Fore.WHITE)) diff --git a/scripts/views.py b/scripts/views.py index 926c28f..107e49f 100755 --- a/scripts/views.py +++ b/scripts/views.py @@ -159,6 +159,7 @@ def views(target, do_assemblies = None): # Find all the scad files # main_blurb = None + pngs = [] for dir in source_dirs(bom_dir): if os.path.isdir(dir): for filename in os.listdir(dir): @@ -185,15 +186,21 @@ def views(target, do_assemblies = None): if not "blurb" in ass: ass["blurb"] = blurb.scrape_module_blurb(lines[:line_no]) break - if not do_assemblies or real_name in do_assemblies: + + # + # Run openscad on the created file + # + dname = deps_name(deps_dir, filename) + for explode in [0, 1]: # - # Run openscad on the created file + # Generate png name # - dname = deps_name(deps_dir, filename) - for explode in [0, 1]: - png_name = target_dir + '/' + real_name + '.png' - if not explode: - png_name = png_name.replace('_assembly', '_assembled') + png_name = target_dir + '/' + real_name + '.png' + if not explode: + png_name = png_name.replace('_assembly', '_assembled') + pngs.append(png_name) + + if not do_assemblies or real_name in do_assemblies: changed = check_deps(png_name, dname) changed = times.check_have_time(changed, png_name) changed = options.have_changed(changed, png_name) @@ -403,16 +410,16 @@ def views(target, do_assemblies = None): # # Convert to HTML # - html_name = 'readme.html' + html_name = top_dir + 'readme.html' t = time.time() - with open(top_dir + html_name, "wt") as html_file: + with open(html_name, "wt") as html_file: do_cmd(("python -m markdown -x tables -x sane_lists " + doc_name).split(), html_file) - times.add_time(top_dir + html_name, t) - times.print_times() + times.add_time(html_name, t) + times.print_times(pngs + [html_name]) # # Make the printme.html by replacing empty spans that invisbly mark the page breaks by page break divs. # - with open(top_dir + 'readme.html', 'rt') as src: + with open(html_name, 'rt') as src: lines = src.readlines() i = 0