From 168ec73b7c8b9ffbac5b92b15590f6b7c8c6a32e Mon Sep 17 00:00:00 2001 From: sirmrak Date: Thu, 21 May 2026 14:09:54 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20Unicode=20syntax=20error=20=D0=B2=20star?= =?UTF-8?q?t=5Fserver.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Проблема: bytes literal с Unicode символами (🔐, ╔, ║ и т.д.) Решение: - HTML response через .encode('utf-8') вместо bytes literal - ASCII box drawing вместо Unicode символов - Убраны emoji из print statements Тест: python3 -m py_compile web-client/start_server.py --- web-client/start_server.py | 54 +++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/web-client/start_server.py b/web-client/start_server.py index 4f1b71e..d54b55e 100755 --- a/web-client/start_server.py +++ b/web-client/start_server.py @@ -60,15 +60,16 @@ class AuthHandler(http.server.SimpleHTTPRequestHandler): self.send_header('Content-type', 'text/html; charset=utf-8') self.end_headers() - self.wfile.write(b''' + html = ''' 401 Unauthorized -

🔐 Wyoming Satellite — Authentication Required

+

Wyoming Satellite - Authentication Required

Please enter the password to access the Web UI.

- ''') + ''' + self.wfile.write(html.encode('utf-8')) def do_GET(self): """Handle GET requests with authentication.""" @@ -111,45 +112,50 @@ def main(): # Create handler with password Handler = create_auth_handler(args.password) - print(f""" -╔══════════════════════════════════════════════════════════╗ -║ 🛰️ Wyoming Satellite WebSocket Client Server ║ -╠══════════════════════════════════════════════════════════╣ -║ Serving: {str(SCRIPT_DIR):<45} ║ -║ URL: http://localhost:{args.port:<36} ║ -║ Remote: http://:{args.port:<32} ║ -║ Password: {'*' * len(args.password):<45} ║ -║ ║ -║ Press Ctrl+C to stop ║ -╚══════════════════════════════════════════════════════════╝ - """) + print(""" ++==========================================================+ +| Wyoming Satellite WebSocket Client Server | ++==========================================================+ +| Serving: {:<53} | +| URL: http://localhost:{:<29} | +| Remote: http://:{:<25} | +| Password: {:<48} | +| | +| Press Ctrl+C to stop | ++==========================================================+ + """.format( + str(SCRIPT_DIR), + args.port, + args.port, + '*' * len(args.password) + )) try: with ReusableTCPServer((args.host, args.port), Handler) as httpd: - print(f"🚀 Server started on http://{args.host}:{args.port}") - print("📖 Serving files from:", SCRIPT_DIR) - print(f"🔐 Password protected ({len(args.password)} characters)") - print("\n⌨️ Press Ctrl+C to stop\n") + print(f"Server started on http://{args.host}:{args.port}") + print("Serving files from:", SCRIPT_DIR) + print(f"Password protected ({len(args.password)} characters)") + print("\nPress Ctrl+C to stop\n") try: httpd.serve_forever() except KeyboardInterrupt: - print("\n👋 Shutting down gracefully...") + print("\nShutting down gracefully...") # Shutdown in a separate thread to avoid deadlock shutdown_thread = threading.Thread(target=httpd.shutdown) shutdown_thread.start() shutdown_thread.join(timeout=2) httpd.server_close() - print("✅ Server stopped successfully") + print("Server stopped successfully") except OSError as e: - print(f"\n❌ Error: Could not bind to port {args.port}") + print(f"\nError: Could not bind to port {args.port}") print(f" {e}") - print("\n💡 Try using a different port:") + print("\nTry using a different port:") print(f" python3 {sys.argv[0]} --port 8081\n") sys.exit(1) except Exception as e: - print(f"\n❌ Unexpected error: {e}") + print(f"\nUnexpected error: {e}") sys.exit(1)