From 07169c7be2b68ea55962eac60744ecd963efd22c Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Wed, 3 Jun 2015 17:52:30 +0200 Subject: [PATCH] Report how many preview snippets fail. Instead of warning about latex problems that, most probably, are worked around by the script, report how many preview snippets were not produced. --- lib/scripts/legacy_lyxpreview2ppm.py | 13 +++++++++---- lib/scripts/lyxpreview2bitmap.py | 6 +++++- lib/scripts/lyxpreview_tools.py | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/scripts/legacy_lyxpreview2ppm.py b/lib/scripts/legacy_lyxpreview2ppm.py index 732e3b158a..63013dbe4c 100644 --- a/lib/scripts/legacy_lyxpreview2ppm.py +++ b/lib/scripts/legacy_lyxpreview2ppm.py @@ -305,7 +305,7 @@ def legacy_conversion_step1(latex_file, dpi, output_format, fg_color, bg_color, # Compile the latex file. latex_status, latex_stdout = run_latex(latex, latex_file) if latex_status: - warning("trying to recover from failed compilation") + progress("Will try to recover from %s failure" % latex) if pdf_output: return legacy_conversion_step3(latex_file, dpi, output_format, True, skipMetrics) @@ -516,9 +516,11 @@ def legacy_conversion_step3(latex_file, dpi, output_format, dvips_failed, skipMe # Pass failed pages to pdflatex if len(failed_pages) > 0: warning("Now trying to obtain failed previews through pdflatex") - legacy_conversion_pdflatex(latex_file, failed_pages, legacy_metrics, - use_pdftocairo, conv, gs_device, gs_ext, alpha, resolution, - output_format) + error_count = legacy_conversion_pdflatex(latex_file, failed_pages, + legacy_metrics, use_pdftocairo, conv, gs_device, gs_ext, alpha, + resolution, output_format) + else: + error_count = 0 # Invalidate metrics for pages that produced errors if len(error_pages) > 0: @@ -526,6 +528,7 @@ def legacy_conversion_step3(latex_file, dpi, output_format, dvips_failed, skipMe if index not in failed_pages: legacy_metrics.pop(index - 1) legacy_metrics.insert(index - 1, (index, -1.0)) + error_count += 1 # Crop the ppm images if pnmcrop != None and output_format == "ppm": @@ -537,6 +540,8 @@ def legacy_conversion_step3(latex_file, dpi, output_format, dvips_failed, skipMe # Extract metrics info from the log file. metrics_file = latex_file_re.sub(".metrics", latex_file) write_metrics_info(legacy_metrics, metrics_file) + if error_count: + warning("Failed to produce %d preview snippet(s)" % error_count) return (0, legacy_metrics) diff --git a/lib/scripts/lyxpreview2bitmap.py b/lib/scripts/lyxpreview2bitmap.py index 7121b1e112..8aaaaaf56b 100755 --- a/lib/scripts/lyxpreview2bitmap.py +++ b/lib/scripts/lyxpreview2bitmap.py @@ -471,7 +471,7 @@ def main(argv): error_pages = [] latex_status, latex_stdout = run_latex(latex, latex_file, bibtex) if latex_status: - warning("trying to recover from failed compilation") + progress("Will try to recover from %s failure" % latex) error_pages = check_latex_log(latex_file_re.sub(".log", latex_file)) # The dvi output file name @@ -568,10 +568,14 @@ def main(argv): # Invalidate metrics for pages that produced errors if len(error_pages) > 0: + error_count = 0 for index in error_pages: if index not in ps_pages and index not in pdf_pages: dvipng_metrics.pop(index - 1) dvipng_metrics.insert(index - 1, (index, -1.0)) + error_count += 1 + if error_count: + warning("Failed to produce %d preview snippet(s)" % error_count) # Convert images to ppm format if necessary. if output_format == "ppm": diff --git a/lib/scripts/lyxpreview_tools.py b/lib/scripts/lyxpreview_tools.py index 4b18227746..6766b5f08d 100644 --- a/lib/scripts/lyxpreview_tools.py +++ b/lib/scripts/lyxpreview_tools.py @@ -348,7 +348,7 @@ def run_tex(tex, tex_file): tex_status, tex_stdout = run_command(tex_call) if tex_status: - warning("%s had problems compiling %s" \ + progress("Warning: %s had problems compiling %s" \ % (os.path.basename(tex), tex_file)) return tex_status, tex_stdout -- 2.39.2