Skip to content

Fix/output parent dir and oerpc noise - #1

Closed
stephansainleger wants to merge 3 commits into
0k:masterfrom
stephansainleger:fix/output-parent-dir-and-oerpc-noise
Closed

stephansainleger wants to merge 3 commits into
0k:masterfrom
stephansainleger:fix/output-parent-dir-and-oerpc-noise

Conversation

@stephansainleger

Copy link
Copy Markdown

No description provided.

vaab and others added 3 commits September 10, 2026 18:30
An Odoo user who just wants ``ssh some-machine`` to work had to install a
Python package, learn the right ``uv`` verb, and assemble a command with
four flags — all to run something they touch a few times a year.

``scripts/odoo-get-ssh-config`` does it on a machine that has nothing: it
checks for ``uv`` (whose installer needs no root) and the ``git`` that
fetching from a git reference requires, offers to install what is
missing, asks once for the Odoo server, database, login and bastion
address, saves them to the config file ``warpgate-man`` already reads,
and delegates to the published package through ``uvx``. It never runs
from a checkout, and introduces no config format of its own.

stdout carries the ssh config and nothing else, so
``odoo-get-ssh-config > ~/.ssh/config.d/warpgate`` produces a usable
file: every prompt and progress line goes to stderr, and prompts are read
from ``/dev/tty`` so that redirection stays interactive. A stray line on
stdout would corrupt the result, and ``ssh`` rejects a whole config over
one bad line.

Two details worth keeping:

- ``has_tty`` tests by OPENING ``/dev/tty``, not by ``[ -r ]``. In a
  container the node exists yet opening it fails with ENXIO, and a
  stat-based check would print a prompt nobody can answer.
- Piped to an interpreter (``curl ... | bash``), ``$0`` is the shell, so
  a naive script calls itself ``bash`` and tells the reader to run
  ``bash > ~/.ssh/...``. It recognises itself instead.

The generated config declares no ``api-key`` and omits ``db`` when the
answer is left empty — the two fields just made optional — and never
stores the password: it emits a ``${ODOO_PASSWORD}`` reference and
supplies the variable for that run only. Written ``0600``.

Tests are ``sunit`` (``bin/test-sh``), since pytest cannot cover a script
whose whole point is running before the package is installed. The
fixtures put the sandbox on a CLOSED ``$PATH``: keeping ``/usr/bin``
would leave the real ``git`` visible behind the fake, and a "missing
tool" test would silently exercise the present-tool path and pass for
the wrong reason. Each behaviour was confirmed by breaking it — stdout
pollution, a stored password, a world-readable config, a swallowed
failure, a removed consent prompt, and the ``$0`` fallback all make a
test fail.

Assisted-by: Claude:claude-opus-5
The documented usage writes to ``~/.ssh/config.d/warpgate``, a directory
that does not exist on a fresh machine. ``open(path, "w")`` does not
create parent directories, so the command died with ``FileNotFoundError``
right after authenticating.

Mirror the ``mkdir -p`` already done by ``scripts/odoo-get-ssh-config``
for its own config, so ``--output`` can target a nested path.
``oerpc.api`` imports every API module on first session use and logs an
ERROR for the two that need Python 2's ``cStringIO``. They are irrelevant
to the JSON-RPC transport we use, but with no logging configured Python's
last-resort handler prints them to stderr, ahead of the password prompt.

Attach a ``NullHandler`` to the ``oerpc.api`` logger: it stops the
last-resort output while an explicitly configured root logger still
receives oerpc's messages.
@vaab

vaab commented Sep 13, 2026

Copy link
Copy Markdown
Member

rebased and merged.

@vaab vaab closed this Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants