Initial project import
This commit is contained in:
@@ -3,12 +3,13 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
|
||||
DEFAULT_BASE_URL = "http://docker-gpu.cin.su:8011"
|
||||
DEFAULT_BASE_URL = "http://docker.cin.su:8011"
|
||||
|
||||
|
||||
def rpc(base_url: str, method: str, payload: dict[str, Any]) -> dict[str, Any]:
|
||||
@@ -49,10 +50,15 @@ def discover_module_target(base_url: str, base_id: str, table: str, timeout_seco
|
||||
if not file_name:
|
||||
continue
|
||||
for stream in module.get("streams") or []:
|
||||
if not isinstance(stream, dict) or not stream.get("has_bsl_marker"):
|
||||
if not isinstance(stream, dict):
|
||||
continue
|
||||
preview = str(stream.get("preview") or "")
|
||||
old = "#Если " if "#Если " in preview else "Процедура " if "Процедура " in preview else ""
|
||||
if not stream.get("has_bsl_marker") and not any(
|
||||
marker in preview for marker in ("Процедура ", "Функция ", "&НаКлиенте", "&НаСервере")
|
||||
):
|
||||
continue
|
||||
declaration = re.search(r"(?im)^\s*(?:Процедура|Функция)\s+[A-Za-zА-Яа-яЁё_][\wА-Яа-яЁё]*\s*\([^)]*\)", preview)
|
||||
old = declaration.group(0).strip() if declaration else "#Если " if "#Если " in preview else ""
|
||||
if not old:
|
||||
continue
|
||||
write_plan_target = stream.get("write_plan_target") if isinstance(stream.get("write_plan_target"), dict) else {}
|
||||
@@ -77,6 +83,11 @@ def main() -> int:
|
||||
parser.add_argument("--base-id", default="upo_test")
|
||||
parser.add_argument("--table", default="ConfigCASSave")
|
||||
parser.add_argument("--file-name", default="", help="Saved-state module file name. Empty or placeholder* auto-selects a BSL stream.")
|
||||
parser.add_argument(
|
||||
"--module-ref",
|
||||
default="",
|
||||
help="Exact module_ref returned by discovery. Useful for embedded form modules without a #stream suffix.",
|
||||
)
|
||||
parser.add_argument("--stream-index", type=int, default=4)
|
||||
parser.add_argument("--old", default="Перем Параметры; ")
|
||||
parser.add_argument("--new", default="Перем Параметры; ")
|
||||
@@ -115,13 +126,29 @@ def main() -> int:
|
||||
if auto_target.get("expected_sha1") and not args.expected_sha1:
|
||||
args.expected_sha1 = str(auto_target["expected_sha1"])
|
||||
|
||||
module_ref = f"{args.table}:{args.file_name}#stream:{args.stream_index}"
|
||||
module_ref = str(
|
||||
args.module_ref
|
||||
or auto_target.get("module_ref")
|
||||
or f"{args.table}:{args.file_name}#stream:{args.stream_index}"
|
||||
)
|
||||
saved_state = rpc(
|
||||
args.base_url,
|
||||
"metadata.saved_state.modules.search",
|
||||
{
|
||||
"base_id": args.base_id,
|
||||
"tables": [args.table],
|
||||
"file_name": args.file_name,
|
||||
"limit": 1,
|
||||
"scan_limit": 10,
|
||||
"include_storage": True,
|
||||
"timeout_seconds": args.timeout_seconds,
|
||||
},
|
||||
)
|
||||
saved_state_preflight = {
|
||||
"status": saved_state.get("status"),
|
||||
"counts": saved_state.get("counts") or {},
|
||||
}
|
||||
if args.allow_empty_saved_state:
|
||||
saved_state = rpc(
|
||||
args.base_url,
|
||||
"metadata.saved_state.modules.search",
|
||||
{"base_id": args.base_id, "tables": [args.table], "limit": 1, "scan_limit": 100, "timeout_seconds": args.timeout_seconds},
|
||||
)
|
||||
if saved_state.get("status") == "ok" and ((saved_state.get("counts") or {}).get("modules") or 0) == 0:
|
||||
result = {
|
||||
"schema": "onec_module_stream_write_smoke.v1",
|
||||
@@ -157,6 +184,10 @@ def main() -> int:
|
||||
result = {
|
||||
"schema": "onec_module_stream_write_smoke.v1",
|
||||
"status": "write_failed",
|
||||
"base_id": args.base_id,
|
||||
"table": args.table,
|
||||
"module_ref": module_ref,
|
||||
"saved_state_preflight": saved_state_preflight,
|
||||
"metadata_write": written,
|
||||
"write_plan": write_plan,
|
||||
}
|
||||
@@ -185,7 +216,7 @@ def main() -> int:
|
||||
"base_id": args.base_id,
|
||||
"table": args.table,
|
||||
"module_ref": module_ref,
|
||||
**({"saved_state_preflight": auto_target.get("discovery")} if auto_target else {}),
|
||||
"saved_state_preflight": saved_state_preflight,
|
||||
"write_plan": {
|
||||
"status": write_plan.get("status"),
|
||||
"allowed": write_plan.get("allowed"),
|
||||
|
||||
Reference in New Issue
Block a user