2424STDIN_CHANNEL = 0
2525STDOUT_CHANNEL = 1
2626STDERR_CHANNEL = 2
27+ ERROR_CHANNEL = 3
28+ RESIZE_CHANNEL = 4
2729
2830
2931class WSClient :
@@ -46,6 +48,10 @@ def __init__(self, configuration, url, headers):
4648 if headers and 'authorization' in headers :
4749 header .append ("authorization: %s" % headers ['authorization' ])
4850
51+ if configuration .ws_streaming_protocol :
52+ header .append ("Sec-WebSocket-Protocol: %s" %
53+ configuration .ws_streaming_protocol )
54+
4955 if url .startswith ('wss://' ) and configuration .verify_ssl :
5056 ssl_opts = {
5157 'cert_reqs' : ssl .CERT_REQUIRED ,
@@ -131,10 +137,10 @@ def readline_stderr(self, timeout=None):
131137 return self .readline_channel (STDERR_CHANNEL , timeout = timeout )
132138
133139 def read_all (self ):
134- """Read all of the inputs with the same order they recieved. The channel
135- information would be part of the string. This is useful for
136- non-interactive call where a set of command passed to the API call and
137- their result is needed after the call is concluded.
140+ """Return buffered data received on stdout and stderr channels.
141+ This is useful for non-interactive call where a set of command passed
142+ to the API call and their result is needed after the call is concluded.
143+ Should be called after run_forever() or update()
138144
139145 TODO: Maybe we can process this and return a more meaningful map with
140146 channels mapped for each input.
@@ -174,9 +180,10 @@ def update(self, timeout=0):
174180 channel = ord (data [0 ])
175181 data = data [1 :]
176182 if data :
177- # keeping all messages in the order they received for
178- # non-blocking call.
179- self ._all += data
183+ if channel in [STDOUT_CHANNEL , STDERR_CHANNEL ]:
184+ # keeping all messages in the order they received for
185+ # non-blocking call.
186+ self ._all += data
180187 if channel not in self ._channels :
181188 self ._channels [channel ] = data
182189 else :
0 commit comments