24
24
STDIN_CHANNEL = 0
25
25
STDOUT_CHANNEL = 1
26
26
STDERR_CHANNEL = 2
27
+ ERROR_CHANNEL = 3
28
+ RESIZE_CHANNEL = 4
27
29
28
30
29
31
class WSClient :
@@ -46,6 +48,10 @@ def __init__(self, configuration, url, headers):
46
48
if headers and 'authorization' in headers :
47
49
header .append ("authorization: %s" % headers ['authorization' ])
48
50
51
+ if configuration .ws_streaming_protocol :
52
+ header .append ("Sec-WebSocket-Protocol: %s" %
53
+ configuration .ws_streaming_protocol )
54
+
49
55
if url .startswith ('wss://' ) and configuration .verify_ssl :
50
56
ssl_opts = {
51
57
'cert_reqs' : ssl .CERT_REQUIRED ,
@@ -131,10 +137,10 @@ def readline_stderr(self, timeout=None):
131
137
return self .readline_channel (STDERR_CHANNEL , timeout = timeout )
132
138
133
139
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()
138
144
139
145
TODO: Maybe we can process this and return a more meaningful map with
140
146
channels mapped for each input.
@@ -174,9 +180,10 @@ def update(self, timeout=0):
174
180
channel = ord (data [0 ])
175
181
data = data [1 :]
176
182
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
180
187
if channel not in self ._channels :
181
188
self ._channels [channel ] = data
182
189
else :
0 commit comments