Skip to content

Commit

Permalink
Allow error messages to propagate through pipes
Browse files Browse the repository at this point in the history
The Buddy modules will now detect a traceback and simply print it out and exit, instead of trying to otherwise process the input.
  • Loading branch information
biologyguy committed Feb 3, 2017
1 parent 0c3971f commit f68ce05
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion buddysuite/AlignBuddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ def __init__(self, _input, in_format=None, out_format=None):
# Handles
if str(type(_input)) == "<class '_io.TextIOWrapper'>":
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()
Expand Down
6 changes: 5 additions & 1 deletion buddysuite/PhyloBuddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ def __init__(self, _input, _in_format=None, _out_format=None):
# Handles
if str(type(_input)) == "<class '_io.TextIOWrapper'>":
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()
Expand Down
6 changes: 5 additions & 1 deletion buddysuite/SeqBuddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ def __init__(self, sb_input, in_format=None, out_format=None, alpha=None):
# Handles
if str(type(sb_input)) == "<class '_io.TextIOWrapper'>":
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()
Expand Down

0 comments on commit f68ce05

Please sign in to comment.