mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-07-16 07:45:17 +03:00
fix(skills): ibcmd non-interactive — fast-fail вместо зависания на запросе учётки (#28)
ibcmd при отсутствии/неверных учётных данных уходил в интерактивный запрос и зависал. Эмпирически (реальный ibcmd, macOS+Windows, базы с пользователями): вис возникает только когда не задан -UserName; stdin=DEVNULL НЕ лечит (наоборот виснет). Лечит закрытый stdin-пайп (EOF) → ibcmd падает за ~4-7с с внятным «Идентификация пользователя не выполнена». - python (12 файлов + stub): run_ibcmd(cmd, has_username) c input="" вместо прямого subprocess.run; без таймаута. Остаточный случай python+Windows+нет -UserName (ibcmd читает консоль) помечается hint'ом в stderr (English, model-facing). - PowerShell (12 файлов): Invoke-IbcmdProcess через [System.Diagnostics.Process] + RedirectStandardInput + StandardInput.Close() → fast-fail; StandardOutputEncoding cp866 (кириллица ibcmd не мойибейлится). Ветка 1cv8/DESIGNER не тронута. - Жёсткий таймаут не вводим: у вызывающей стороны свой бэкстоп, авто-kill рвал бы длинные легитимные операции. - Синхронный бамп версий ps1+py всех затронутых навыков. Fixes #28 Co-Authored-By: Korolev Pavel <korolev.vrn@gmail.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# db-dump-xml v1.7 — Dump 1C configuration to XML files
|
||||
# db-dump-xml v1.8 — Dump 1C configuration to XML files
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
|
||||
import argparse
|
||||
@@ -78,6 +78,27 @@ def resolve_v8path(v8path):
|
||||
return v8path
|
||||
|
||||
|
||||
IBCMD_NOUSER_HINT = (
|
||||
"[ibcmd] No -UserName/-Password given; the infobase may require authentication. "
|
||||
"On Windows ibcmd reads credentials from the console (stdin is ignored), so this "
|
||||
"call may block instead of failing. If it does not return promptly, abort and "
|
||||
"re-run with -UserName and -Password.\n"
|
||||
)
|
||||
|
||||
|
||||
def run_ibcmd(cmd, has_username=False, warn_no_user=True):
|
||||
"""Run an ibcmd command non-interactively.
|
||||
|
||||
input="" closes stdin (EOF) so ibcmd's auth prompt fast-fails instead of hanging.
|
||||
On Windows without -UserName ibcmd reads the console directly and may still block —
|
||||
that residual case is flagged via IBCMD_NOUSER_HINT (model-facing).
|
||||
"""
|
||||
if warn_no_user and os.name == "nt" and not has_username:
|
||||
sys.stderr.write(IBCMD_NOUSER_HINT)
|
||||
sys.stderr.flush()
|
||||
return subprocess.run(cmd, input="", capture_output=True, encoding="utf-8", errors="replace")
|
||||
|
||||
|
||||
def main():
|
||||
sys.stdout.reconfigure(encoding="utf-8")
|
||||
sys.stderr.reconfigure(encoding="utf-8")
|
||||
@@ -161,7 +182,7 @@ def main():
|
||||
arguments.append(f"--password={args.Password}")
|
||||
arguments.append(f"--data={ib_data}")
|
||||
print(f"Running: ibcmd {' '.join(arguments)}")
|
||||
result = subprocess.run([v8path] + arguments, capture_output=True, encoding="utf-8", errors="replace")
|
||||
result = run_ibcmd([v8path] + arguments, bool(args.UserName))
|
||||
if result.returncode == 0:
|
||||
print(f"Configuration exported successfully to: {args.ConfigDir}")
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user