Commits

Anonymous committed f22f019

intercept stdout and stderr, so wsgi won't complain

  • Participants
  • Parent commits d2ff544

Comments (0)

Files changed (1)

File hghooks/manager.py

 # You should have received a copy of the GNU Lesser General Public License
 # along with hghooks.  If not, see <http://www.gnu.org/licenses/>.
 
+from cStringIO import StringIO
 from hghooks.checkers import re_options
 from mercurial import match, ignore, util
 import os
 import re
 import shutil
+import sys
 import tempfile
 
 class CheckerManager(object):
                 modified_files[full_path] = filedata
 
         if modified_files:
-            warnings += checker(modified_files)
+            try:
+                stdout_backup = sys.stdout
+                stderr_backup = sys.stderr
+                sys.stdout = sys.stderr = StringIO()
+                warnings += checker(modified_files)
+                stdout = sys.stdout.getvalue()
+                if stdout:
+                    self.ui.warn(stdout)
+            finally:
+                sys.stdout = stdout_backup
+                sys.stderr = stderr_backup
 
         if warnings:
             self.ui.warn('%d warning(s) found\n' % warnings)