]> git.lyx.org Git - lyx.git/commitdiff
Report how many preview snippets fail.
authorEnrico Forestieri <forenr@lyx.org>
Wed, 3 Jun 2015 15:52:30 +0000 (17:52 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Wed, 3 Jun 2015 15:57:09 +0000 (17:57 +0200)
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
lib/scripts/lyxpreview2bitmap.py
lib/scripts/lyxpreview_tools.py

index 732e3b158a8677d4b19588c1fc377e7975c84682..63013dbe4c6ec45b9a75c16d47441ec52c99df7b 100644 (file)
@@ -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)
 
index 7121b1e112c4a8f1f8bf8bfb918a3ed0f4e0bdc0..8aaaaaf56b6fced8c0f4bab0744bbea7056bc0e9 100755 (executable)
@@ -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":
index 4b18227746b037351a93694305c744d803c22e4b..6766b5f08dcb85076aeac98d0f4c0cebcd399d96 100644 (file)
@@ -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