From 9911f3572492172647e9754f77ee9b804fdf3fc3 Mon Sep 17 00:00:00 2001 From: michalpokusa <72110769+michalpokusa@users.noreply.github.com> Date: Thu, 14 Dec 2023 20:22:30 +0000 Subject: [PATCH] Added alternative adafruit_hashlib import and warning message in neither is present --- adafruit_httpserver/response.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/adafruit_httpserver/response.py b/adafruit_httpserver/response.py index 4329a8f..8c6d240 100644 --- a/adafruit_httpserver/response.py +++ b/adafruit_httpserver/response.py @@ -17,9 +17,19 @@ import os import json from binascii import b2a_base64 -import hashlib from errno import EAGAIN, ECONNRESET, ETIMEDOUT, ENOTCONN +try: + try: + import hashlib + except ImportError: + import adafruit_hashlib as hashlib +except ImportError: + print( + "WARNING: hashlib module not available and adafruit_hashlib not installed.", + "Websocket support will not work.", + ) + from .exceptions import ( BackslashInPathError, FileNotExistsError,