Prechádzať zdrojové kódy

docs: Add user-friendly guide about how to use ws_server_example_test.py

Closes https://github.com/espressif/esp-idf/issues/8060
Yuan Jian Min 4 rokov pred
rodič
commit
2a89b3c15a

+ 2 - 1
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.

+ 8 - 14
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

+ 0 - 1
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