From f68ce0589fe56d861b4af7617ebf3cd2ba4017cd Mon Sep 17 00:00:00 2001 From: biologyguy Date: Fri, 3 Feb 2017 13:03:37 -0500 Subject: [PATCH] Allow error messages to propagate through pipes The Buddy modules will now detect a traceback and simply print it out and exit, instead of trying to otherwise process the input. --- buddysuite/AlignBuddy.py | 6 +++++- buddysuite/PhyloBuddy.py | 6 +++++- buddysuite/SeqBuddy.py | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/buddysuite/AlignBuddy.py b/buddysuite/AlignBuddy.py index fb57a1a..66d100d 100755 --- a/buddysuite/AlignBuddy.py +++ b/buddysuite/AlignBuddy.py @@ -90,7 +90,11 @@ def __init__(self, _input, in_format=None, out_format=None): # Handles if str(type(_input)) == "": if not _input.seekable(): # Deal with input streams (e.g., stdout pipes) - temp = StringIO(br.utf_encode(_input.read())) + input_txt = _input.read() + if re.search("Buddy::.* has crashed with the following traceback", input_txt): + print(input_txt) + sys.exit() + temp = StringIO(br.utf_encode(input_txt)) _input = temp _input.seek(0) in_handle = _input.read() diff --git a/buddysuite/PhyloBuddy.py b/buddysuite/PhyloBuddy.py index 2fafcc6..b14aa91 100755 --- a/buddysuite/PhyloBuddy.py +++ b/buddysuite/PhyloBuddy.py @@ -167,7 +167,11 @@ def __init__(self, _input, _in_format=None, _out_format=None): # Handles if str(type(_input)) == "": if not _input.seekable(): # Deal with input streams (e.g., stdout pipes) - temp = StringIO(br.utf_encode(_input.read())) + input_txt = _input.read() + if re.search("Buddy::.* has crashed with the following traceback", input_txt): + print(input_txt) + sys.exit() + temp = StringIO(br.utf_encode(input_txt)) _input = temp _input.seek(0) in_from_handle = _input.read() diff --git a/buddysuite/SeqBuddy.py b/buddysuite/SeqBuddy.py index f94b7e7..849231a 100755 --- a/buddysuite/SeqBuddy.py +++ b/buddysuite/SeqBuddy.py @@ -185,7 +185,11 @@ def __init__(self, sb_input, in_format=None, out_format=None, alpha=None): # Handles if str(type(sb_input)) == "": if not sb_input.seekable(): # Deal with input streams (e.g., stdout pipes) - temp = StringIO(br.utf_encode(sb_input.read())) + input_txt = sb_input.read() + if re.search("Buddy::.* has crashed with the following traceback", input_txt): + print(input_txt) + sys.exit() + temp = StringIO(br.utf_encode(input_txt)) sb_input = temp sb_input.seek(0) in_handle = sb_input.read()