From 34fda8f71120ee2f35388912649c5c82da075b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=97=E8=BE=9E?= Date: Thu, 11 Sep 2025 11:49:06 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20PyWebPageAPI.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PyWebPageAPI.py | 78 ------------------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 PyWebPageAPI.py diff --git a/PyWebPageAPI.py b/PyWebPageAPI.py deleted file mode 100644 index 39f4ba5..0000000 --- a/PyWebPageAPI.py +++ /dev/null @@ -1,78 +0,0 @@ -import os -import sys -import importlib -import platform -import ProjectCfg -def EnvironmentCheck() -> bool: - """ - 检查环境是否符合要求 - :return: - """ - if sys.version_info < ProjectCfg.PYTHON_VERSION_MIN and ProjectCfg.PYTHON_VERSION_MIN!=(0,0): - return False - if sys.version_info > ProjectCfg.PYTHON_VERSION_MAX and ProjectCfg.PYTHON_VERSION_MAX!=(0,0): - return False - for lib in ProjectCfg.LIB_LIST: - if importlib.util.find_spec(lib) is None: - return False - if platform.system() not in ProjectCfg.SUPPORTED_PLATFORMS and ProjectCfg.SUPPORTED_PLATFORMS!=['All']: - return False - return True - -def CheckWebviewInstalled() -> tuple[bool,str]: - """ - 检查WebView框架是否已安装 - :return: - """ - system_platform : str = platform.system() - - if system_platform == "Windows": - # 检查WebView2 - webview2_path : str = r'C:\Program Files (x86)\Microsoft\EdgeWebView2' - webview2_dll : str = r'\WebView2Loader.dll' - for root, dirs, files in os.walk(webview2_path): - if webview2_dll in files: - return (True,'') - return (False,"No installed WebView2") - - elif system_platform == "Darwin": - # 检查WebKit框架 - webkit_path = '/System/Library/Frameworks/WebKit.framework' - if os.path.exists(webkit_path): - return (True,'') - return (False,"Unsupported WKWebView") - - elif system_platform == "Linux": - # 检查WebKitGTK - webkitgtk_paths = [ - '/usr/lib/libwebkit2gtk-4.0.so', - '/usr/lib/x86_64-linux-gnu/libwebkit2gtk-4.0.so' - ] - for path in webkitgtk_paths: - if os.path.exists(path): - return (True,'') - - # 检查QtWebEngine - qtwebengine_paths = [ - '/usr/lib/qt5/bin/qtwebengine_process', - '/usr/lib/x86_64-linux-gnu/qt5/bin/qtwebengine_process' - ] - for path in qtwebengine_paths: - if os.path.exists(path): - return "QtWebEngine已安装" - - return (False,"Not Found Webview framework.") - - else: - return (False,"Unsupported OS.") - -def CheckPortAvailable(port : int) -> bool: - """ - 检查端口是否可用 - :param port: - :return: - """ - import socket - with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - return s.connect_ex(('localhost', port)) != 0 - return False \ No newline at end of file