From dfc02cfa42d85bfb5e538d1270c626bb411482fe Mon Sep 17 00:00:00 2001 From: Alejo Rossia Date: Tue, 24 Feb 2026 16:17:16 +0100 Subject: [PATCH 1/2] Windows-compatible reports Changes required to make the report function work on Windows too. The should still run as usual on Linux/Mac but requires verification. --- src/smefit/analyze/__init__.py | 17 ++++++++++------- src/smefit/analyze/html_utils.py | 12 ++++++++---- src/smefit/analyze/latex_tools.py | 5 ++++- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/smefit/analyze/__init__.py b/src/smefit/analyze/__init__.py index 8b76c9e1..b039dfd8 100644 --- a/src/smefit/analyze/__init__.py +++ b/src/smefit/analyze/__init__.py @@ -2,7 +2,7 @@ import pathlib import shutil import subprocess - +import sys import yaml from matplotlib import rc, use @@ -69,14 +69,17 @@ def run_report(report_card_file): # Move all files to a meta folder meta_path = pathlib.Path(f"{report_folder}/meta").absolute() meta_path.mkdir() - subprocess.call(f"mv {report_folder}/*.* {meta_path}", shell=True) + for f in report_folder.glob("*.*"): + shutil.move(str(f), meta_path) # Combine PDF files together into raw pdf report - subprocess.call( - f"gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \ - -sOutputFile={report_folder}/report_{report_name}.pdf `ls -rt {meta_path}/*.pdf`", - shell=True, - ) + pdf_files = sorted(meta_path.glob("*.pdf"), key=os.path.getmtime) + gs_cmd = "gswin64c" if sys.platform == "win32" else "gs" + subprocess.call([ + gs_cmd, "-q", "-dNOPAUSE", "-dBATCH", "-sDEVICE=pdfwrite", + f"-sOutputFile={report_folder}/report_{report_name}.pdf", + *[str(f) for f in pdf_files], + ]) # dump html index dump_html_index( diff --git a/src/smefit/analyze/html_utils.py b/src/smefit/analyze/html_utils.py index 7dcd7c82..85b5ac45 100644 --- a/src/smefit/analyze/html_utils.py +++ b/src/smefit/analyze/html_utils.py @@ -106,10 +106,14 @@ def run_htlatex(report_path, tex_file): new_style = report_path.joinpath("style.css") shutil.copyfile(style_css, new_style) # title = tex_file.stem.replace("_", " ") - subprocess.call( - f"pandoc {tex_file} --standalone --mathjax --output {tex_file.with_suffix('.html')} --metadata title=' ' -c {new_style.stem}.css", - shell=True, - ) + subprocess.call([ + "pandoc", str(tex_file), + "--standalone", + "--mathjax", + "--output", str(tex_file.with_suffix('.html')), + "--metadata", "title= ", + "-c", f"{new_style.stem}.css", + ]) def dump_html_index(html_report, html_index, report_path, report_title): diff --git a/src/smefit/analyze/latex_tools.py b/src/smefit/analyze/latex_tools.py index 4b9e9c42..41457086 100644 --- a/src/smefit/analyze/latex_tools.py +++ b/src/smefit/analyze/latex_tools.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +import os import pathlib import subprocess @@ -84,7 +85,9 @@ def run_pdflatex(report, filename): f"pdflatex -halt-on-error -output-directory {report} {filename}.tex > {report}/pdflatex.log", shell=True, ) - subprocess.call(f"rm {report}/*.log {report}/*.aux {report}/*.out", shell=True) + for ext in ["*.log", "*.aux", "*.out"]: + for f in report.glob(ext): + os.remove(f) def compile_tex(report, L, filename): From 68bf6fa42395cce02273c188f33b2a0c0caaa3aa Mon Sep 17 00:00:00 2001 From: Alejo Rossia Date: Tue, 24 Feb 2026 16:28:27 +0100 Subject: [PATCH 2/2] Added os in __init__.py --- src/smefit/analyze/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/smefit/analyze/__init__.py b/src/smefit/analyze/__init__.py index b039dfd8..55bd92b3 100644 --- a/src/smefit/analyze/__init__.py +++ b/src/smefit/analyze/__init__.py @@ -3,6 +3,7 @@ import shutil import subprocess import sys +import os import yaml from matplotlib import rc, use