當前位置: 首頁>>代碼示例>>Python>>正文


Python ABNF.OPCODE_TEXT屬性代碼示例

本文整理匯總了Python中websocket.ABNF.OPCODE_TEXT屬性的典型用法代碼示例。如果您正苦於以下問題:Python ABNF.OPCODE_TEXT屬性的具體用法?Python ABNF.OPCODE_TEXT怎麽用?Python ABNF.OPCODE_TEXT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在websocket.ABNF的用法示例。


在下文中一共展示了ABNF.OPCODE_TEXT屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: recv

# 需要導入模塊: from websocket import ABNF [as 別名]
# 或者: from websocket.ABNF import OPCODE_TEXT [as 別名]
def recv(self):
        if self._ws_client is None:
            raise WebsocketNotConnectedException()

        opcode, data = None, None

        while opcode != ABNF.OPCODE_TEXT:
            opcode, data = self._ws_client.recv_data()

        return data.decode("utf-8") if PY3 else data 
開發者ID:neptune-ai,項目名稱:neptune-client,代碼行數:12,代碼來源:websocket_client_adapter.py

示例2: write_channel

# 需要導入模塊: from websocket import ABNF [as 別名]
# 或者: from websocket.ABNF import OPCODE_TEXT [as 別名]
def write_channel(self, channel, data):
        """Write data to a channel."""
        # check if we're writing binary data or not
        binary = six.PY3 and type(data) == six.binary_type
        opcode = ABNF.OPCODE_BINARY if binary else ABNF.OPCODE_TEXT

        channel_prefix = chr(channel)
        if binary:
            channel_prefix = six.binary_type(channel_prefix, "ascii")

        payload = channel_prefix + data
        self.sock.send(payload, opcode=opcode) 
開發者ID:kubernetes-client,項目名稱:python-base,代碼行數:14,代碼來源:ws_client.py

示例3: update

# 需要導入模塊: from websocket import ABNF [as 別名]
# 或者: from websocket.ABNF import OPCODE_TEXT [as 別名]
def update(self, timeout=0):
        """Update channel buffers with at most one complete frame of input."""
        if not self.is_open():
            return
        if not self.sock.connected:
            self._connected = False
            return
        r, _, _ = select.select(
            (self.sock.sock, ), (), (), timeout)
        if r:
            op_code, frame = self.sock.recv_data_frame(True)
            if op_code == ABNF.OPCODE_CLOSE:
                self._connected = False
                return
            elif op_code == ABNF.OPCODE_BINARY or op_code == ABNF.OPCODE_TEXT:
                data = frame.data
                if six.PY3:
                    data = data.decode("utf-8", "replace")
                if len(data) > 1:
                    channel = ord(data[0])
                    data = data[1:]
                    if data:
                        if channel in [STDOUT_CHANNEL, STDERR_CHANNEL]:
                            # keeping all messages in the order they received
                            # for non-blocking call.
                            self._all.write(data)
                        if channel not in self._channels:
                            self._channels[channel] = data
                        else:
                            self._channels[channel] += data 
開發者ID:kubernetes-client,項目名稱:python-base,代碼行數:32,代碼來源:ws_client.py

示例4: recv_data

# 需要導入模塊: from websocket import ABNF [as 別名]
# 或者: from websocket.ABNF import OPCODE_TEXT [as 別名]
def recv_data(self, control_frame=False):
        if self.returndata:
            return ABNF.OPCODE_TEXT, self.returndata.pop(0)
        else:
            raise ssl.SSLWantReadError() 
開發者ID:wee-slack,項目名稱:wee-slack,代碼行數:7,代碼來源:conftest.py

示例5: update

# 需要導入模塊: from websocket import ABNF [as 別名]
# 或者: from websocket.ABNF import OPCODE_TEXT [as 別名]
def update(self, timeout=0):
        """Update channel buffers with at most one complete frame of input."""
        if not self.is_open():
            return
        if not self.sock.connected:
            self._connected = False
            return
        r, _, _ = select.select(
            (self.sock.sock, ), (), (), timeout)
        if r:
            op_code, frame = self.sock.recv_data_frame(True)
            if op_code == ABNF.OPCODE_CLOSE:
                self._connected = False
                return
            elif op_code == ABNF.OPCODE_BINARY or op_code == ABNF.OPCODE_TEXT:
                data = frame.data
                if six.PY3:
                    data = data.decode("utf-8")
                if len(data) > 1:
                    channel = ord(data[0])
                    data = data[1:]
                    if data:
                        if channel in [STDOUT_CHANNEL, STDERR_CHANNEL]:
                            # keeping all messages in the order they received for
                            # non-blocking call.
                            self._all += data
                        if channel not in self._channels:
                            self._channels[channel] = data
                        else:
                            self._channels[channel] += data 
開發者ID:aws-samples,項目名稱:aws-kube-codesuite,代碼行數:32,代碼來源:ws_client.py


注:本文中的websocket.ABNF.OPCODE_TEXT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。