fix: 兼容 ocr_plugin 的嵌套目录结构
This commit is contained in:
+15
-8
@@ -139,14 +139,21 @@ def export_pdf_image_tables_local(excel_app, file_path, excel_path, pages_str, l
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# 查找插件路径
|
# 查找插件路径 (支持直接在 ocr_plugin 下,也支持嵌套在 ocr_worker 下)
|
||||||
plugin_exe = os.path.join(os.getcwd(), "ocr_plugin", "ocr_worker.exe")
|
plugin_paths = [
|
||||||
if not os.path.exists(plugin_exe):
|
os.path.join(os.getcwd(), "ocr_plugin", "ocr_worker.exe"),
|
||||||
# 尝试查找相对 main.py / exe 的路径
|
os.path.join(os.getcwd(), "ocr_plugin", "ocr_worker", "ocr_worker.exe"),
|
||||||
app_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "ocr_plugin", "ocr_worker.exe"),
|
||||||
plugin_exe = os.path.join(app_dir, "ocr_plugin", "ocr_worker.exe")
|
os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "ocr_plugin", "ocr_worker", "ocr_worker.exe")
|
||||||
|
]
|
||||||
if not os.path.exists(plugin_exe):
|
|
||||||
|
plugin_exe = None
|
||||||
|
for p in plugin_paths:
|
||||||
|
if os.path.exists(p):
|
||||||
|
plugin_exe = p
|
||||||
|
break
|
||||||
|
|
||||||
|
if not plugin_exe:
|
||||||
raise Exception("未检测到本地 AI 插件!请下载 'ocr_plugin' 文件夹并放置在程序同一目录下。")
|
raise Exception("未检测到本地 AI 插件!请下载 'ocr_plugin' 文件夹并放置在程序同一目录下。")
|
||||||
|
|
||||||
if log_func:
|
if log_func:
|
||||||
|
|||||||
Reference in New Issue
Block a user