Issue 2332 (preparation): refactor print statements so we can
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 6 Apr 2010 15:13:51 +0000 (15:13 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 6 Apr 2010 15:13:51 +0000 (15:13 +0000)
transition to using the Python 2.6 io.StringIO class.

git-svn-id: http://scons.tigris.org/svn/scons/trunk@4773 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Tool/latex.py
src/engine/SCons/Tool/pdflatex.py
src/engine/SCons/Tool/pdftex.py
src/engine/SCons/Tool/tex.py

index 90adbabf1201805bc9d90229fbdd36a92a631e9a..283a8b49c2602a718e90681d06e9447304d9483e 100644 (file)
@@ -44,7 +44,7 @@ import SCons.Tool.tex
 def LaTeXAuxFunction(target = None, source= None, env=None):
     result = SCons.Tool.tex.InternalLaTeXAuxAction( SCons.Tool.tex.LaTeXAction, target, source, env )
     if result != 0:
-        print env['LATEX']," returned an error, check the log file"
+        SCons.Tool.tex.check_file_error_message(env['LATEX'])
     return result
 
 LaTeXAuxAction = SCons.Action.Action(LaTeXAuxFunction,
index 167de5118898fd1fb7d5529d8c9ad2604ed301e3..78204d9008231966b9bcbf60c808940edf21547a 100644 (file)
@@ -44,7 +44,7 @@ PDFLaTeXAction = None
 def PDFLaTeXAuxFunction(target = None, source= None, env=None):
     result = SCons.Tool.tex.InternalLaTeXAuxAction( PDFLaTeXAction, target, source, env )
     if result != 0:
-        print env['PDFLATEX']," returned an error, check the log file"
+        SCons.Tool.tex.check_file_error_message(env['PDFLATEX'])
     return result
 
 PDFLaTeXAuxAction = None
index 4fadf5efe57e9f31718f0a24ab9113cf45c83c2a..33a41f29bf3c57b34fc01b929d803e28227312a5 100644 (file)
@@ -59,11 +59,11 @@ def PDFTeXLaTeXFunction(target = None, source= None, env=None):
     if SCons.Tool.tex.is_LaTeX(source,env,abspath):
         result = PDFLaTeXAuxAction(target,source,env)
         if result != 0:
-            print env['PDFLATEX']," returned an error, check the log file"
+            SCons.Tool.tex.check_file_error_message(env['PDFLATEX'])
     else:
         result = PDFTeXAction(target,source,env)
         if result != 0:
-            print env['PDFTEX']," returned an error, check the log file"
+            SCons.Tool.tex.check_file_error_message(env['PDFTEX'])
     return result
 
 PDFTeXLaTeXAction = None
index 4960c5d758a9be837723bf79f58ca5b98e8e690b..3a84d21631f03a67e719975d68735710f5cd470c 100644 (file)
@@ -37,6 +37,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 import os.path
 import re
 import shutil
+import sys
 
 import SCons.Action
 import SCons.Node
@@ -132,6 +133,10 @@ _null = SCons.Scanner.LaTeX._null
 
 modify_env_var = SCons.Scanner.LaTeX.modify_env_var
 
+def check_file_error_message(utility, filename='log'):
+    msg = '%s returned an error, check the %s file\n' % (utility, filename)
+    sys.stdout.write(msg)
+
 def FindFile(name,suffixes,paths,env,requireExt=False):
     if requireExt:
         name,ext = SCons.Util.splitext(name)
@@ -297,7 +302,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None
                         bibfile = env.fs.File(targetbase)
                         result = BibTeXAction(bibfile, bibfile, env)
                         if result != 0:
-                            print env['BIBTEX']," returned an error, check the blg file"
+                            check_file_error_message(env['BIBTEX'], 'blg')
                             return result
                         must_rerun_latex = check_MD5(suffix_nodes['.bbl'],'.bbl')
                         break
@@ -310,7 +315,7 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None
             idxfile = suffix_nodes['.idx']
             result = MakeIndexAction(idxfile, idxfile, env)
             if result != 0:
-                print env['MAKEINDEX']," returned an error, check the ilg file"
+                check_file_error_message(env['MAKEINDEX'], 'ilg')
                 return result
 
         # TO-DO: need to add a way for the user to extend this list for whatever
@@ -328,7 +333,8 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None
             nclfile = suffix_nodes['.nlo']
             result = MakeNclAction(nclfile, nclfile, env)
             if result != 0:
-                print env['MAKENCL']," (nomenclature) returned an error, check the nlg file"
+                check_file_error_message('%s (nomenclature)' % env['MAKENCL'],
+                                         'nlg')
                 #return result
 
         # Now decide if latex will need to be run again due to glossary.
@@ -339,7 +345,8 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None
             glofile = suffix_nodes['.glo']
             result = MakeGlossaryAction(glofile, glofile, env)
             if result != 0:
-                print env['MAKEGLOSSARY']," (glossary) returned an error, check the glg file"
+                check_file_error_message('%s (glossary)' % env['MAKEGLOSSARY'],
+                                         'glg')
                 #return result
 
         # Now decide if latex will need to be run again due to acronyms.
@@ -350,7 +357,8 @@ def InternalLaTeXAuxAction(XXXLaTeXAction, target = None, source= None, env=None
             acrfile = suffix_nodes['.acn']
             result = MakeAcronymsAction(acrfile, acrfile, env)
             if result != 0:
-                print env['MAKEACRONYMS']," (acronymns) returned an error, check the alg file"
+                check_file_error_message('%s (acronyms)' % env['MAKEACRONYMS'],
+                                         'alg')
                 return result
 
         # Now decide if latex needs to be run yet again to resolve warnings.
@@ -487,11 +495,11 @@ def TeXLaTeXFunction(target = None, source= None, env=None):
     if is_LaTeX(source,env,abspath):
         result = LaTeXAuxAction(target,source,env)
         if result != 0:
-            print env['LATEX']," returned an error, check the log file"
+            check_file_error_message(env['LATEX'])
     else:
         result = TeXAction(target,source,env)
         if result != 0:
-            print env['TEX']," returned an error, check the log file"
+            check_file_error_message(env['TEX'])
     return result
 
 def TeXLaTeXStrFunction(target = None, source= None, env=None):