From 2a89b3c15ae59b396deab9a0301acb2f7cd27ea3 Mon Sep 17 00:00:00 2001 From: Yuan Jian Min Date: Sun, 2 Jan 2022 11:27:05 +0000 Subject: [PATCH] docs: Add user-friendly guide about how to use ws_server_example_test.py Closes https://github.com/espressif/esp-idf/issues/8060 --- .../http_server/ws_echo_server/README.md | 3 ++- .../ws_echo_server/ws_server_example_test.py | 22 +++++++------------ tools/ci/check_copyright_ignore.txt | 1 - 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/examples/protocols/http_server/ws_echo_server/README.md b/examples/protocols/http_server/ws_echo_server/README.md index 34254b6e48..e8f4d24818 100644 --- a/examples/protocols/http_server/ws_echo_server/README.md +++ b/examples/protocols/http_server/ws_echo_server/README.md @@ -6,7 +6,8 @@ This example demonstrates the HTTPD server using the WebSocket feature. ## How to Use Example The example starts a websocket server on a local network. You need a websocket client to interact with the server (an example test -ws_server_example_test.py could be used as the simple websocket client). +ws_server_example_test.py could be used as the simple websocket client). If you run ws_server_example_test.py and get +`ModuleNotFoundError: No module named 'websocket'`, then please install `websocket` by running `python -m pip install websocket-client`. The server registers websocket handler which echoes back the received WebSocket frame. It also demonstrates use of asynchronous send, which is triggered on reception of a certain message. diff --git a/examples/protocols/http_server/ws_echo_server/ws_server_example_test.py b/examples/protocols/http_server/ws_echo_server/ws_server_example_test.py index d223d32ce4..2767051752 100644 --- a/examples/protocols/http_server/ws_echo_server/ws_server_example_test.py +++ b/examples/protocols/http_server/ws_echo_server/ws_server_example_test.py @@ -1,18 +1,7 @@ #!/usr/bin/env python # -# Copyright 2020 Espressif Systems (Shanghai) PTE LTD -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Apache-2.0 from __future__ import division, print_function, unicode_literals @@ -20,9 +9,14 @@ import os import re import ttfw_idf -import websocket from tiny_test_fw import Utility +try: + import websocket +except ImportError: + print("Please install 'websocket' by running 'python -m pip install websocket-client'") + raise + OPCODE_TEXT = 0x1 OPCODE_BIN = 0x2 OPCODE_PING = 0x9 diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 690bb6877c..8f5cc7c8d8 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -2849,7 +2849,6 @@ examples/protocols/http_server/restful_server/main/rest_server.c examples/protocols/http_server/simple/http_server_simple_test.py examples/protocols/http_server/simple/main/main.c examples/protocols/http_server/ws_echo_server/main/ws_echo_server.c -examples/protocols/http_server/ws_echo_server/ws_server_example_test.py examples/protocols/https_mbedtls/main/https_mbedtls_example_main.c examples/protocols/https_request/example_test.py examples/protocols/https_request/main/https_request_example_main.c