Skip to main content

Resolve the current build (number + SSH host) of an odoo.sh branch from Python

Project description

s6r-odoo-sh

Resolve the current build of an odoo.sh branch — its build number and its live SSH host — from Python.

Odoo.sh recycles old dev builds, so the SSH host of a branch changes on every rebuild and any host cached elsewhere quickly dies. The current build lives only in the odoo.sh dashboard (a GitHub-OAuth-gated Odoo instance), whose generic RPC is locked down. s6r-odoo-sh reads it through the dashboard's own JSON routes.

How it works

  • Runtime is httpx-only (light). It reuses a persisted browser session and, if the odoo.sh session expired but the GitHub session is still alive, the GitHub OAuth code flow replays transparently while following redirects.
  • Login is interactive and one-time (the "PyCharm / gh auth login" model): a browser window opens once for the GitHub login, the session is persisted, and every subsequent call runs headless. This step needs the optional login extra (Playwright); the runtime does not.

Install

pip install s6r-odoo-sh                 # runtime only (httpx)
pip install "s6r-odoo-sh[login]"        # + Playwright, for the one-time login
s6r-odoo-sh --install-browser           # download the Playwright browser (once)

CLI

# one-time interactive login (opens a browser window)
s6r-odoo-sh --login -p grandiflora BRANCH

# current build of a branch (headless afterwards)
s6r-odoo-sh migration_19_v1 -p grandiflora
s6r-odoo-sh migration_19_v1 -p grandiflora --ssh-host   # host string only
s6r-odoo-sh --list          -p grandiflora              # all branches

# ODOO_SH_PROJECT / ODOO_SH_STATE env vars are honored as defaults

Example output:

{
  "project": "grandiflora",
  "branch": "migration_19_v1",
  "stage": "dev",
  "build_id": 34305175,
  "host_slug": "grandiflora-migration-19-v1-34305175",
  "status": "done",
  "result": "success",
  "ssh_host": "34305175@grandiflora-migration-19-v1-34305175.dev.odoo.com"
}

Python API

from s6r_odoo_sh import OdooShClient, resolve

# one-shot (auto-login on first use)
build = resolve("grandiflora", "migration_19_v1")
print(build["build_id"], build["ssh_host"])

# reusable client, custom session path
client = OdooShClient(state_path="/path/to/state.json")
host = client.get_ssh_host("grandiflora", "migration_19_v1", auto_login=True)
for b in client.list_branches("grandiflora"):
    print(b["name"], b["last_build_id"])

OdooShClient(state_path=None, base_url="https://www.odoo.sh", login_browser="firefox", login_timeout=300)state_path defaults to $XDG_CONFIG_HOME/odoo-sh/state.json. NeedLogin is raised when no valid session exists and auto_login is not set.

License

LGPL-3.0-or-later.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

s6r_odoo_sh-0.1.0.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

s6r_odoo_sh-0.1.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file s6r_odoo_sh-0.1.0.tar.gz.

File metadata

  • Download URL: s6r_odoo_sh-0.1.0.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for s6r_odoo_sh-0.1.0.tar.gz
Algorithm Hash digest
SHA256 be4d726e26c21a185040f81ae5eb779c5df6a5e0b9db39a7cc71d174c1a6c919
MD5 4e01f504c38de1bd608114c472cd4b6a
BLAKE2b-256 e022ef3429c7a1577e07a1160e516adf6190075673b7eab6e6ece1e2f13bb28a

See more details on using hashes here.

File details

Details for the file s6r_odoo_sh-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: s6r_odoo_sh-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for s6r_odoo_sh-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a2a636eb20848c382f7526bf12ef5b1d22068f98e3b25d3236bad4b161eebac
MD5 878b874c466265997e315a356bae3fb4
BLAKE2b-256 28aef732ec15a1fc1de2a885116eac0abf27ac9d409826ea0aeb4adf1f702df8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page