/
Paff
/
declarant
Обзор
Документация
Войти
/
Paff
/
declarant
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
_check_server_ocr.py
63 строки
2 KB
1pash1985-gif
Unified doc list UI + AI prompt for FORM_A
05 авг 2026, 10:09
05 авг 2026, 10:09
e439f08
Код
Авторство
О чём код?
# -*- coding: utf-8 -*- import os import sys import paramiko try: sys.stdout.reconfigure(encoding='utf-8') except Exception: pass HOST = os.environ.get('DEPLOY_HOST', '104.171.138.49') USER = os.environ.get('DEPLOY_USER', 'root') PASS = os.environ.get('DEPLOY_PASS') if not PASS: print('Set DEPLOY_PASS environment variable', file=sys.stderr) sys.exit(1) CMD = ( 'docker exec declarant-app python -c "' 'import sys; sys.path.insert(0, chr(47)+chr(97)+chr(112)+chr(112)); ' 'from ocr_eur1 import is_ocr_available; ' 'import shutil, os; ' 'print(chr(102)+chr(105)+chr(116)+chr(122), __import__(chr(102)+chr(105)+chr(116)+chr(122)).__version__); ' 'print(chr(116)+chr(101)+chr(115)+chr(115), __import__(chr(115)+chr(104)+chr(117)+chr(116)+chr(105)+chr(108)).which(chr(116)+chr(101)+chr(115)+chr(115)+chr(101)+chr(114)+chr(97)+chr(99)+chr(116))); ' 'print(chr(111)+chr(99)+chr(114), is_ocr_available())' '"' ) # Simpler version CMD2 = """docker exec declarant-app python -c " import sys sys.path.insert(0, '/app') import shutil, os try: import fitz print('fitz:', fitz.__version__) except Exception as e: print('fitz err:', e) try: import pytesseract print('pytesseract: ok, tesseract bin:', shutil.which('tesseract')) except Exception as e: print('pytesseract err:', e) try: import paddleocr print('paddleocr: installed') except Exception as e: print('paddleocr: not installed') from ocr_eur1 import is_ocr_available print('is_ocr_available:', is_ocr_available()) " """ client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(HOST, username=USER, password=PASS, timeout=30) stdin, stdout, stderr = client.exec_command(CMD2, get_pty=False) out = stdout.read().decode('utf-8', errors='replace') err = stderr.read().decode('utf-8', errors='replace') client.close() print('STDOUT:\n', out) if err.strip(): print('STDERR:\n', err[:2000])