Browse Source

cropping of graphs improved

sx_rewrite
Holger Frey 5 years ago
parent
commit
63ec564de3
  1. 1
      s3printlog/analysis.py
  2. 10
      s3printlog/main.py
  3. 22
      s3printlog/report.py

1
s3printlog/analysis.py

@ -6,6 +6,7 @@ import seaborn as sns @@ -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

10
s3printlog/main.py

@ -56,7 +56,9 @@ def process_drop_checks(log_files): @@ -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): @@ -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): @@ -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)

22
s3printlog/report.py

@ -53,7 +53,8 @@ def trim_image(image_path): @@ -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): @@ -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):

Loading…
Cancel
Save