Add auto-create dir Input
This commit is contained in:
parent
ae78c67952
commit
50c69fb882
@ -18,6 +18,7 @@ from .file_manager import (
|
|||||||
check_input_dir_access,
|
check_input_dir_access,
|
||||||
connect_samba,
|
connect_samba,
|
||||||
create_run_context,
|
create_run_context,
|
||||||
|
ensure_dir_exists,
|
||||||
move_file_to_error,
|
move_file_to_error,
|
||||||
move_file_to_processed,
|
move_file_to_processed,
|
||||||
read_remote_file_bytes,
|
read_remote_file_bytes,
|
||||||
@ -70,6 +71,19 @@ def run_batch(
|
|||||||
smb_base_path=smb_base_path,
|
smb_base_path=smb_base_path,
|
||||||
user_params={"user_name": samba_user, "password": samba_password},
|
user_params={"user_name": samba_user, "password": samba_password},
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
|
ensure_dir_exists(input_dir, samba_conn)
|
||||||
|
except Exception as exc: # noqa: BLE001
|
||||||
|
return BatchResult(
|
||||||
|
status="error",
|
||||||
|
processed=0,
|
||||||
|
partial=0,
|
||||||
|
errors=1,
|
||||||
|
report_path="",
|
||||||
|
protocol_path="",
|
||||||
|
log_path="",
|
||||||
|
messages=[f"Не удалось создать входную папку: {input_dir}. {exc}"],
|
||||||
|
)
|
||||||
is_ok, access_error = check_input_dir_access(
|
is_ok, access_error = check_input_dir_access(
|
||||||
input_dir=input_dir, samba_conn=samba_conn
|
input_dir=input_dir, samba_conn=samba_conn
|
||||||
)
|
)
|
||||||
|
|||||||
@ -2,7 +2,11 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from app.pipeline.file_manager import check_input_dir_access, connect_samba
|
from app.pipeline.file_manager import (
|
||||||
|
check_input_dir_access,
|
||||||
|
connect_samba,
|
||||||
|
ensure_dir_exists,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def build_user_params(samba_user: str, samba_password: str) -> dict[str, str]:
|
def build_user_params(samba_user: str, samba_password: str) -> dict[str, str]:
|
||||||
@ -27,6 +31,11 @@ def check_access_and_list_files(
|
|||||||
except RuntimeError as exc:
|
except RuntimeError as exc:
|
||||||
return False, str(exc), []
|
return False, str(exc), []
|
||||||
|
|
||||||
|
try:
|
||||||
|
ensure_dir_exists(input_dir, samba_conn=samba_conn)
|
||||||
|
except Exception as exc: # noqa: BLE001
|
||||||
|
return False, f"Не удалось создать входную папку: {input_dir}. {exc}", []
|
||||||
|
|
||||||
ok, error = check_input_dir_access(Path(input_dir), samba_conn=samba_conn)
|
ok, error = check_input_dir_access(Path(input_dir), samba_conn=samba_conn)
|
||||||
if not ok:
|
if not ok:
|
||||||
return False, error or "Ошибка доступа к входной папке.", []
|
return False, error or "Ошибка доступа к входной папке.", []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user