- Drop SMB/SAMBA subsystem completely: app/samba_access.py, app/path_settings.py, app/path_store.py, app/pipeline/file_manager.py and their tests, plus the smbprotocol dependency and all related UI (login/password fields, path editor, SMB diagnostics) in main.py. - run_batch now takes a .zip attached via Streamlit's file_uploader (same as the local dev tool) instead of reading from SMB or a fictitious OpenCloud "Attach" folder; renamed from run_local_zip_batch since it's now the single canonical batch entrypoint used by both main.py and scripts/local_zip_test_app.py. - Fixed run number resolution: added next_opencloud_run_number() which lists the Out/year/month/day folder via WebDAV PROPFIND, so repeated runs land in incrementing subfolders instead of always overwriting "1". - Added a self-service "Добавить токен" popover in main.py so users can link their own OpenCloud App Token to their Keycloak account (opencloud_token_store) without an admin running the CLI script; reworded the missing-token error to point at it.
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
from __future__ import annotations
|
||
|
||
import re
|
||
from datetime import datetime
|
||
|
||
FILE_NAME_PATTERNS = (
|
||
re.compile(r"^SKO115FZ_\d{2}_[A-Za-zА-Яа-я0-9]{9}_\d{8}_(?:[ХX]\d{5}|\d{6})\.xml$"),
|
||
)
|
||
|
||
DEFAULT_OUTPUT_DIR_NAME = "Out"
|
||
|
||
REPORT_FILE_TEMPLATE = "report_{date_key}_{run_number}.xlsx"
|
||
PROTOCOL_FILE_TEMPLATE = "protocol_{date_key}_{run_number}.xlsx"
|
||
PROCESS_LOG_FILE_TEMPLATE = "process_{date_key}_{run_number}.log"
|
||
|
||
|
||
def validate_file_name(file_name: str) -> bool:
|
||
return any(pattern.match(file_name) for pattern in FILE_NAME_PATTERNS)
|
||
|
||
|
||
def build_date_parts(now: datetime | None = None) -> tuple[str, str, str, str]:
|
||
current = now or datetime.now()
|
||
year = str(current.year)
|
||
month = str(current.month)
|
||
day = str(current.day)
|
||
date_key = current.strftime("%Y%m%d")
|
||
return year, month, day, date_key
|
||
|
||
|
||
def build_report_file_name(date_key: str, run_number: int) -> str:
|
||
return REPORT_FILE_TEMPLATE.format(date_key=date_key, run_number=run_number)
|
||
|
||
|
||
def build_protocol_file_name(date_key: str, run_number: int) -> str:
|
||
return PROTOCOL_FILE_TEMPLATE.format(date_key=date_key, run_number=run_number)
|
||
|
||
|
||
def build_process_log_file_name(date_key: str, run_number: int) -> str:
|
||
return PROCESS_LOG_FILE_TEMPLATE.format(date_key=date_key, run_number=run_number)
|