diff rhodecode/lib/subprocessio.py @ 3397:64c194492aad beta

--version command should be safe, and bare no modifications - improved subprocess calls error detection - fixed I/O read on closed file errors
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 25 Feb 2013 17:16:45 +0100
parents 4b7ad342e53b
children
line wrap: on
line diff
--- a/rhodecode/lib/subprocessio.py	Mon Feb 25 16:49:05 2013 +0100
+++ b/rhodecode/lib/subprocessio.py	Mon Feb 25 17:16:45 2013 +0100
@@ -119,7 +119,11 @@
         kr = self.keep_reading
         da = self.data_added
         go = self.go
-        b = s.read(cs)
+
+        try:
+            b = s.read(cs)
+        except ValueError:
+            b = ''
 
         while b and go.is_set():
             if len(t) > ccm:
@@ -372,7 +376,9 @@
             bg_out.stop()
             bg_err.stop()
             err = '%s' % ''.join(bg_err)
-            raise EnvironmentError("Subprocess exited due to an error:\n" + err)
+            if err:
+                raise EnvironmentError("Subprocess exited due to an error:\n" + err)
+            raise EnvironmentError("Subprocess exited with non 0 ret code:%s" % _returncode)
 
         self.process = _p
         self.output = bg_out