-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
33 lines (24 loc) · 974 Bytes
/
app.py
File metadata and controls
33 lines (24 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
from pathlib import Path
import pytesseract
from slack_bolt.adapter.socket_mode import SocketModeHandler
def _configure_tesseract_cmd() -> None:
"""Configure pytesseract executable path in a portable way."""
env_cmd = (os.getenv("TESSERACT_CMD") or "").strip()
if env_cmd and Path(env_cmd).exists():
pytesseract.pytesseract.tesseract_cmd = env_cmd
return
candidates = [
r"C:\Program Files\Tesseract-OCR\tesseract.exe",
r"C:\Program Files (x86)\Tesseract-OCR\tesseract.exe",
r"D:\Tesseract-OCR\tesseract.exe",
]
for cmd in candidates:
if Path(cmd).exists():
pytesseract.pytesseract.tesseract_cmd = cmd
return
# If no explicit path is found, keep the default so pytesseract can resolve via PATH.
_configure_tesseract_cmd()
from zh_cosearch_agent_app import app, SLACK_APP_TOKEN
if __name__ == "__main__":
SocketModeHandler(app, SLACK_APP_TOKEN).start()