MCPcopy Index your code
hub / github.com/kubernetes-client/python / __init__

Method __init__

kubernetes/base/stream/ws_client.py:52–80  ·  view source on GitHub ↗

A websocket client with support for channels. Exec command uses different channels for different streams. for example, 0 is stdin, 1 is stdout and 2 is stderr. Some other API calls like port forwarding can forward different pods' streams to different channels.

(self, configuration, url, headers, capture_all, binary=False)

Source from the content-addressed store, hash-verified

50
51class WSClient:
52 def __init__(self, configuration, url, headers, capture_all, binary=False):
53 """A websocket client with support for channels.
54
55 Exec command uses different channels for different streams. for
56 example, 0 is stdin, 1 is stdout and 2 is stderr. Some other API calls
57 like port forwarding can forward different pods' streams to different
58 channels.
59 """
60 self._connected = False
61 self._channels = {}
62 self._closed_channels = set()
63 self.subprotocol = None
64 self.binary = binary
65 self.newline = '\n' if not self.binary else b'\n'
66 if capture_all:
67 self._all = StringIO() if not self.binary else BytesIO()
68 else:
69 self._all = _IgnoredIO()
70 self.sock = create_websocket(configuration, url, headers)
71 self.subprotocol = getattr(self.sock, 'subprotocol', None)
72 if not self.subprotocol and self.sock:
73 headers_dict = self.sock.getheaders()
74 if headers_dict:
75 for k, v in headers_dict.items():
76 if k.lower() == 'sec-websocket-protocol':
77 self.subprotocol = v
78 break
79 self._connected = True
80 self._returncode = None
81
82 def peek_channel(self, channel, timeout=0):
83 """Peek a channel and return part of the input,

Callers

nothing calls this directly

Calls 4

_IgnoredIOClass · 0.85
create_websocketFunction · 0.85
getheadersMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected