mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Check for boolean values first. Fixes #9742.
Instead of raising `RuntimeError`, raise `TerminalException`.
This commit is contained in:
parent
c361079fd5
commit
6daa55c069
@ -156,31 +156,41 @@ class Terminal(object):
|
||||
# ----- Direct Streaming Setup -------------------------------------->
|
||||
if stream_stdout is True:
|
||||
self.stream_stdout = sys.stdout
|
||||
elif stream_stdout is False:
|
||||
self.stream_stdout = None
|
||||
elif stream_stdout is not None:
|
||||
if not hasattr(stream_stdout, 'write') or \
|
||||
not hasattr(stream_stdout, 'flush') or \
|
||||
not hasattr(stream_stdout, 'close'):
|
||||
raise RuntimeError(
|
||||
raise TerminalException(
|
||||
'\'stream_stdout\' needs to have at least 3 methods, '
|
||||
'\'write()\', \'flush()\' and \'close()\'.'
|
||||
)
|
||||
self.stream_stdout = stream_stdout
|
||||
else:
|
||||
self.stream_stdout = None
|
||||
raise TerminalException(
|
||||
'Don\'t know how to handle {0!r} as the VT\'s '
|
||||
'\'stream_stdout\' parameter.'.format(stream_stdout)
|
||||
)
|
||||
|
||||
if stream_stderr is True:
|
||||
self.stream_stderr = sys.stderr
|
||||
elif stream_stderr is False:
|
||||
self.stream_stderr = None
|
||||
elif stream_stderr is not None:
|
||||
if not hasattr(stream_stderr, 'write') or \
|
||||
not hasattr(stream_stderr, 'flush') or \
|
||||
not hasattr(stream_stderr, 'close'):
|
||||
raise RuntimeError(
|
||||
raise TerminalException(
|
||||
'\'stream_stderr\' needs to have at least 3 methods, '
|
||||
'\'write()\', \'flush()\' and \'close()\'.'
|
||||
)
|
||||
self.stream_stderr = stream_stderr
|
||||
else:
|
||||
self.stream_stderr = None
|
||||
raise TerminalException(
|
||||
'Don\'t know how to handle {0!r} as the VT\'s '
|
||||
'\'stream_stderr\' parameter.'.format(stream_stderr)
|
||||
)
|
||||
# <---- Direct Streaming Setup ---------------------------------------
|
||||
|
||||
# ----- Spawn our terminal ------------------------------------------>
|
||||
|
Loading…
Reference in New Issue
Block a user