[PATCH v1 1/2] git-p4: print stderr if P4 read_pipe operation fails
- From
larsxschneider@gmail.com <larsxschneider@gmail.com>
- Date
- Sep 7, 2015, 12:42 UTC
- Message-ID
- <1441629723-90604-2-git-send-email-larsxschneider@gmail.com>
- In-Reply-To
- <1441629723-90604-1-git-send-email-larsxschneider@gmail.com>
From: Lars Schneider <larsxschneider@gmail.com>
If read_pipe crashes then the caller can inspect the error and handle it appropriately.
Signed-off-by: Lars Schneider <larsxschneider@gmail.com> --- git-p4.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-p4.py b/git-p4.py index 073f87b..36a4bcb 100755 --- a/git-p4.py +++ b/git-p4.py @@ -134,11 +134,11 @@ def read_pipe(c, ignore_error=False): sys.stderr.write('Reading pipe: %s\n' % str(c)) expand = isinstance(c,basestring) - p = subprocess.Popen(c, stdout=subprocess.PIPE, shell=expand) + p = subprocess.Popen(c, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=expand) pipe = p.stdout val = pipe.read() if p.wait() and not ignore_error: - die('Command failed: %s' % str(c)) + die('Command failed: %s\nError: %s' % (str(c), p.stderr.read())) return val
-- 2.5.1