diff --git a/s3printlog/analysis.py b/s3printlog/analysis.py index 9436384..cdc506f 100644 --- a/s3printlog/analysis.py +++ b/s3printlog/analysis.py @@ -6,6 +6,7 @@ import seaborn as sns import pathlib from pandas.plotting import register_matplotlib_converters + register_matplotlib_converters() from .logparser import CheckWhen, CheckResult diff --git a/s3printlog/main.py b/s3printlog/main.py index e665d42..3ead6d4 100644 --- a/s3printlog/main.py +++ b/s3printlog/main.py @@ -56,7 +56,9 @@ def process_drop_checks(log_files): plt.savefig(image_path) missing_drop_df = find_missing_drops(drop_log_df) - misssing_drop_list_path = log_files.folder / f"{log_files.folder.name}_missed_spots.xlsx" + misssing_drop_list_path = ( + log_files.folder / f"{log_files.folder.name}_missed_spots.xlsx" + ) missing_drop_df.to_excel(misssing_drop_list_path) return DropProcessResult( @@ -72,9 +74,12 @@ def process_print_log(log_files): image_path = log_files.folder / f"{log_files.folder.name}_environment.png" plt.savefig(image_path) - tmp_result = PrintLogResult(ProcessResult(print_log.environment, image_path), print_log.info) + tmp_result = PrintLogResult( + ProcessResult(print_log.environment, image_path), print_log.info + ) return augment_print_info(tmp_result, log_files.drop_check) + def process_log_files(log_files): drop_check_result = process_drop_checks(log_files) print_log_result = process_print_log(log_files) @@ -86,6 +91,7 @@ def process_log_files(log_files): print_log_result.info, ) + def process_log_folder(folder): log_files = get_log_files(folder) return process_log_files(log_files) diff --git a/s3printlog/report.py b/s3printlog/report.py index 9f7e714..44521eb 100644 --- a/s3printlog/report.py +++ b/s3printlog/report.py @@ -53,7 +53,8 @@ def trim_image(image_path): background = PIL.Image.new(original.mode, original.size, original.getpixel((0, 0))) diff = PIL.ImageChops.difference(original, background) diff = PIL.ImageChops.add(diff, diff, 2.0, -100) - bbox = diff.getbbox() + left, upper, right, lower = diff.getbbox() + bbox = (left - 10, upper - 10, right + 12, lower + 10) cropped = original.crop(bbox) if bbox else original buffer = io.BytesIO() cropped.save(buffer, format="png") @@ -126,14 +127,17 @@ def print_info_flowable(print_info): f"{print_info['humidity']} (humidifier might be turned off)", ), ] - return Table(data, style=[ - ('TOPPADDING', (0, 0), (-1, -1), 0), - ('RIGHTPADDING', (0, 0), (-1, -1), 7), - ('BOTTOMPADDING', (0, 0), (-1, -1), 0), - ('LEFTPADDING', (0, 0), (-1, -1), 0), - ('FONTSIZE', (0, 0), (-1, -1), 8), -],hAlign='LEFT' - ) + return Table( + data, + style=[ + ("TOPPADDING", (0, 0), (-1, -1), 0), + ("RIGHTPADDING", (0, 0), (-1, -1), 7), + ("BOTTOMPADDING", (0, 0), (-1, -1), 0), + ("LEFTPADDING", (0, 0), (-1, -1), 0), + ("FONTSIZE", (0, 0), (-1, -1), 8), + ], + hAlign="LEFT", + ) def generate_report(log_files, drops, missing, environment, print_info):