gOdoo-cli 0.3.14__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/PKG-INFO +4 -1
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/pyproject.toml +5 -1
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/setup.py +6 -2
- godoo_cli-0.4.1/src/godoo_cli/cli.py +79 -0
- godoo_cli-0.4.1/src/godoo_cli/cli_common.py +191 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/commands/__init__.py +3 -2
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/commands/bootstrap.py +30 -75
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/commands/config.py +6 -4
- godoo_cli-0.4.1/src/godoo_cli/commands/db/__init__.py +1 -0
- godoo_cli-0.4.1/src/godoo_cli/commands/db/cli.py +14 -0
- godoo_cli-0.4.1/src/godoo_cli/commands/db/connection.py +51 -0
- godoo_cli-0.4.1/src/godoo_cli/commands/db/passwords.py +53 -0
- godoo_cli-0.4.1/src/godoo_cli/commands/launch.py +320 -0
- godoo_cli-0.4.1/src/godoo_cli/commands/rpc/cli.py +31 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/commands/rpc/importer.py +14 -13
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/commands/rpc/modules.py +17 -22
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/commands/rpc/translations.py +53 -18
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/commands/shell.py +15 -12
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/commands/source_get.py +50 -35
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/commands/test.py +38 -11
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/helpers/cli.py +54 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/helpers/system.py +9 -2
- godoo_cli-0.4.1/src/godoo_cli/version.py +1 -0
- godoo_cli-0.3.14/src/godoo_cli/cli.py +0 -105
- godoo_cli-0.3.14/src/godoo_cli/commands/launch.py +0 -158
- godoo_cli-0.3.14/src/godoo_cli/commands/rpc/cli.py +0 -24
- godoo_cli-0.3.14/src/godoo_cli/commands/rpc/cli_callbacks.py +0 -41
- godoo_cli-0.3.14/src/godoo_cli/version.py +0 -1
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/LICENSE +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/README.md +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/__init__.py +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/__main__.py +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/commands/rpc/__init__.py +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/git/__init__.py +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/git/git_odoo.py +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/git/git_odoo_addons.py +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/git/git_repo.py +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/git/git_url.py +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/git/zip_download.py +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/helpers/__init__.py +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/helpers/bootstrap.py +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/helpers/odoo_files.py +0 -0
- {godoo_cli-0.3.14 → godoo_cli-0.4.1}/src/godoo_cli/helpers/odoo_manifest.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: godoo-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.1
|
|
4
4
|
Summary: Wrapper around Odoo-Bin with some convinience RPC functions.
|
|
5
5
|
Home-page: https://github.com/OpenJKSoftware/gOdoo
|
|
6
6
|
License: LGPL-3
|
|
@@ -23,8 +23,11 @@ Requires-Dist: godoo-rpc (==0.0.3)
|
|
|
23
23
|
Requires-Dist: inotify (>=0.2.10,<0.3.0) ; extra == "devcontainer"
|
|
24
24
|
Requires-Dist: ipdb (>=0.13.9,<0.14.0) ; extra == "devcontainer"
|
|
25
25
|
Requires-Dist: isort (>=5.10.1,<6.0.0) ; extra == "codequality"
|
|
26
|
+
Requires-Dist: mock (>=4.0.3,<5.0.0) ; extra == "devcontainer"
|
|
26
27
|
Requires-Dist: openupgradelib (>=3.3.4,<4.0.0)
|
|
28
|
+
Requires-Dist: passlib (>=1.7.4,<2.0.0)
|
|
27
29
|
Requires-Dist: pre-commit (>=2.20.0,<3.0.0) ; extra == "devcontainer"
|
|
30
|
+
Requires-Dist: psycopg2 (>=2.9.5,<3.0.0)
|
|
28
31
|
Requires-Dist: py-spy (>=0.3.11,<0.4.0) ; extra == "devcontainer"
|
|
29
32
|
Requires-Dist: pylint-odoo (>=8.0.16,<9.0.0) ; extra == "codequality"
|
|
30
33
|
Requires-Dist: python-dotenv (>=0.20.0,<0.21.0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "gOdoo-cli"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.1"
|
|
4
4
|
description = "Wrapper around Odoo-Bin with some convinience RPC functions."
|
|
5
5
|
authors = ["Joshua Kreuder <Joshua_Kreuder@outlook.com>"]
|
|
6
6
|
license = "LGPL-3"
|
|
@@ -23,6 +23,8 @@ gitpython = "^3.1.27"
|
|
|
23
23
|
rich = "^12.6.0"
|
|
24
24
|
godoo-rpc = "0.0.3"
|
|
25
25
|
openupgradelib = "^3.3.4"
|
|
26
|
+
psycopg2 = "^2.9.5"
|
|
27
|
+
passlib = "^1.7.4"
|
|
26
28
|
|
|
27
29
|
pylint-odoo = { version="^8.0.16", optional = true}
|
|
28
30
|
ipdb = { version="^0.13.9", optional = true}
|
|
@@ -35,6 +37,7 @@ py-spy = { version="^0.3.11", optional = true}
|
|
|
35
37
|
rope = { version="^0.23.0", optional = true}
|
|
36
38
|
flake8 = { version="^5.0.4", optional = true}
|
|
37
39
|
inotify = { version="^0.2.10",optional = true}
|
|
40
|
+
mock = { version="^4.0.3", optional= true}
|
|
38
41
|
|
|
39
42
|
[tool.poetry.extras]
|
|
40
43
|
devcontainer = [
|
|
@@ -45,6 +48,7 @@ devcontainer = [
|
|
|
45
48
|
"rope",
|
|
46
49
|
"py-spy",
|
|
47
50
|
"inotify",
|
|
51
|
+
"mock",
|
|
48
52
|
]
|
|
49
53
|
codequality = [
|
|
50
54
|
"pylint-odoo",
|
|
@@ -7,6 +7,7 @@ package_dir = \
|
|
|
7
7
|
packages = \
|
|
8
8
|
['godoo_cli',
|
|
9
9
|
'godoo_cli.commands',
|
|
10
|
+
'godoo_cli.commands.db',
|
|
10
11
|
'godoo_cli.commands.rpc',
|
|
11
12
|
'godoo_cli.git',
|
|
12
13
|
'godoo_cli.helpers']
|
|
@@ -18,6 +19,8 @@ install_requires = \
|
|
|
18
19
|
['gitpython>=3.1.27,<4.0.0',
|
|
19
20
|
'godoo-rpc==0.0.3',
|
|
20
21
|
'openupgradelib>=3.3.4,<4.0.0',
|
|
22
|
+
'passlib>=1.7.4,<2.0.0',
|
|
23
|
+
'psycopg2>=2.9.5,<3.0.0',
|
|
21
24
|
'python-dotenv>=0.20.0,<0.21.0',
|
|
22
25
|
'rich>=12.6.0,<13.0.0',
|
|
23
26
|
'ruamel-yaml>=0.17.21,<0.18.0',
|
|
@@ -34,14 +37,15 @@ extras_require = \
|
|
|
34
37
|
'watchdog>=2.1.7,<3.0.0',
|
|
35
38
|
'py-spy>=0.3.11,<0.4.0',
|
|
36
39
|
'rope>=0.23.0,<0.24.0',
|
|
37
|
-
'inotify>=0.2.10,<0.3.0'
|
|
40
|
+
'inotify>=0.2.10,<0.3.0',
|
|
41
|
+
'mock>=4.0.3,<5.0.0']}
|
|
38
42
|
|
|
39
43
|
entry_points = \
|
|
40
44
|
{'console_scripts': ['godoo = godoo_cli:launch_cli']}
|
|
41
45
|
|
|
42
46
|
setup_kwargs = {
|
|
43
47
|
'name': 'godoo-cli',
|
|
44
|
-
'version': '0.
|
|
48
|
+
'version': '0.4.1',
|
|
45
49
|
'description': 'Wrapper around Odoo-Bin with some convinience RPC functions.',
|
|
46
50
|
'long_description': '# gOdoo Dev Environment\n\n\n\n\n[<img src="https://raw.githubusercontent.com/OpenJKSoftware/gOdoo/main/assets/godoo-main-cli.png" width="1000"/>](image.png)\n\n**gOdoo** is short for **go Odoo**. \\\nIt is a [Vscode Devcontainer](https://code.visualstudio.com/docs/remote/containers) Environment for [Odoo](https://odoo.com/)\nwith Python CLI `godoo` convenience wrapper around `odoo-bin`.\n\nThis repository is the base source for the Python package [godoo-cli](https://pypi.org/project/godoo-cli/) and serves as\nan all batteries included development environment.\n\nMade Possible by: [WEMPE Elektronic GmbH](https://wetech.de)\n\n# gOdoo-cli\n\nPython package that provides `godoo` command line interface around `odoo-bin`.\n\nIt\'s build with [Typer](https://github.com/tiangolo/typer) to provide some convenience Wrappers for Odoo development and\nDeployment.\n\nMost flags can be configured by Env variables. \\\nUse `godoo --help` to find out more. HINT: Install tab-completion with `godoo --install-completion`\n\n# Docker\n\nThis workspace also contains Docker and Docker-Compose files. \\\n\nThey are used to provide either easy Odoo instances where the source is pulled according to\n[ODOO_MANIFEST.yml](./ODOO_MANIFEST.yml), or as a all batteries included devcontainer for VScode.\n\n## Requirements\n\n- [Docker Compose](https://github.com/docker/compose)\n- [Traefik](https://doc.traefik.io/traefik/) container running with docker provider and "traefik" named docker network.\n Example: [Traefik Devproxy](https://github.com/joshkreud/traefik_devproxy)\n- SSH Agent running. (check `echo $SSH_AUTH_SOCK`)\\\n This gets passed trough in the Buildprocess to clone Thirdparty repos.\n\n## Just wanna have a quick and easy Odoo Instance?\n\n```bash\ngit clone https://github.com/OpenJKSoftware/gOdoo\ncd godoo\n. scripts/container_requirements.sh # Check Requirements\ndocker-compose build\ndocker-compose up\n# wait......\n# wait a bit mode ...\n# just a little bit longer ..\n# There we go.\n# Odoo should be reachable on \'https://godoo.docker.localhost\' assuming you didn\'t change .env TRAEFIK_HOST_RULE or COMPOSE_PROJECT_NAME\n```\n\n# Devcontainer\n\n## Features\n\n- All batteries included [Devcontainer](https://code.visualstudio.com/docs/remote/containers) with postgres service\n Container and local DNS resolvig managed by [Traefik](https://doc.traefik.io/traefik/).\n- Easy fully working Odoo instance by `docker-compose up` with https access.\n- `godoo` CLI wrapper around Odoo. (Most flags can be configured by Environment Variables and are already preconfigured\n in the Containers. See [.env.sample](./.env.sample))\n- `odoo-bin` is added to PATH and can thus be invoked from every folder.\n- Odoo will run in Proxy_Mode behind a Traefik reverse proxy for easy access on\n `https://$COMPOSE_PROJECT_NAME.docker.localhost`\n- [Odoo Pylint plugin](https://github.com/OCA/pylint-odoo) preconfigured in vscode\n- Preinstalled vscode Extensions Highlights:\n - [SQL Tools](https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools) with preconfigured connection for\n easy Database access in the Sidebar.\n - [Docker Extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker) controls\n container host.\n - [Odoo Snippets](https://marketplace.visualstudio.com/items?itemName=mstuttgart.odoo-snippets)\n - [Odoo Developments](https://marketplace.visualstudio.com/items?itemName=scapigliato.vsc-odoo-development) can Grab\n Odoo Model information from a running Server\n - [Todo Tree](https://marketplace.visualstudio.com/items?itemName=Gruntfuggly.todo-tree)\n\n## Usage\n\n1. For Docker on windows: Clone the repo into the WSL2 Filesystem for better IO performance\n2. Have [Traefik](https://github.com/traefik/traefik) Running on `docker.localhost`\n [Example](https://github.com/joshkreud/traefik_devproxy) \\\n There must be a Docker network called `traefik` that can reach traefik.\n3. Open Devcontianer:\n - If you have the Devcontainer CLI: `devcontainer open .`\n - If not open the workspace in Local Vscode. In the Command pallete search for `Reopen in container`\n4. From **within the container** start Odoo using one of the following commands:\n - You can enable godoo tab-completion by `godoo --install-completion`\n - `make` -> Loads Odoo + Workspace Addons\n - `make bare` -> Loads Odoo with ony `web` installed.\n - `make kill` -> Search for `odoo-bin` processes and kill them\n - `make reset` -> Drops DB, deletes config file and datafolder\n - The full init script is available via "`godoo`". (See --help for Options)\n5. Open Odoo `https://$COMPOSE_PROJECT_NAME.docker.localhost`\\\n For example `COMPOSE_PROJECT_NAME=godoo` --> [https://godoo.docker.localhost](https://godoo.docker.localhost)\n6. Login with `admin:admin`\n7. Profit!\n\n### Access to Odoo and Thirdparty addon Source\n\nYou can access the Odoo source by opening the VsCode workspace [full.code-workspace](full.code-workspace) from within\nthe Container. This will open a [Multi-Root Workspace](https://code.visualstudio.com/docs/editor/multi-root-workspaces).\nReally waiting for https://github.com/microsoft/vscode-remote-release/issues/3665 here.\n\n## Reset Devcontainer Data\n\nWhen you screwed up so bad its time to just start Over godoo has you covered:\n\n### Automatic Reset\n\nThere are 3 Options to reset the Dev Env.\n\n1. From **Outside** the Container run `make reset` in the project root to delete docker volumes and restart the\n container. (Vscode will prompt to reconnect if still open)\n2. From **Outside** the Container run `make reset-hard` in the project root to force rebuild the main Odoo container and\n then do the same as `make reset`\n3. From **Inside** the Container run `make reset` to drop the DB and delete varlib and the bootstrap flag, which is way\n quicker than the other options.\n\n### Manual Reset\n\n1. Close vscode\n2. Remove `app` and `db` container from docker.\n3. Remove volumes: `db, odoo_thirdparty, odoo_web, vscode_extensions`\n4. Restart Devcontainer\n\n## Python Debugging\n\n### VsCode Debugging\n\nDebugging doesn\'t reliably work with\n[Odoo Multiprocess](https://www.odoo.com/documentation/14.0/developer/misc/other/cmdline.html#multiprocessing) mode\nenabled. \\\nThe container ships with a Vscode Debug profile, that sets `--workers 0` to allow for Debugging Breakpoints. See [.vscode/launch.json](./.vscode/launch.json)\n\n### Interactive Shell\n\nUse `godoo shell` to enter an interactive shell on the Database.\n\n# Odoo Modules\n\n## Third Party Modules (manifest.yml)\n\nThe `godoo` bootstrap function, will download some modules using git. \\\nWhich Repos to download is specified in `ODOO_MANIFEST.yml` ([Default](./ODOO_MANIFEST.yml)) \\\nNot all of the cloned addons are automatically installed. \\\nInstall them via the Apps Page in Odoo using `godoo rpc modules install` or using `odoo-bin`.\\\nModules downloaded on the Odoo Marketplace can be dropped as a `.zip` archive in [./thirdparty](./thirdparty)\n',
|
|
47
51
|
'author': 'Joshua Kreuder',
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""Main CLI."""
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
import typer
|
|
5
|
+
from dotenv import load_dotenv
|
|
6
|
+
from rich import print as rich_print
|
|
7
|
+
|
|
8
|
+
from .cli_common import CommonCLI
|
|
9
|
+
from .commands import (
|
|
10
|
+
bootstrap_odoo,
|
|
11
|
+
db_cli_app,
|
|
12
|
+
launch_import,
|
|
13
|
+
launch_odoo,
|
|
14
|
+
odoo_shell,
|
|
15
|
+
odoo_test,
|
|
16
|
+
rpc_cli_app,
|
|
17
|
+
set_odoo_config,
|
|
18
|
+
source_cli_app,
|
|
19
|
+
uninstall_modules,
|
|
20
|
+
)
|
|
21
|
+
from .helpers.odoo_files import odoo_bin_get_version
|
|
22
|
+
from .helpers.system import set_logging
|
|
23
|
+
from .version import __version__
|
|
24
|
+
|
|
25
|
+
CLI = CommonCLI()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def main_callback(
|
|
29
|
+
verbose: Optional[bool] = typer.Option(False, "--verbose", "-v", help="Verbose Logging with Error stacktraces")
|
|
30
|
+
):
|
|
31
|
+
set_logging(verbose=verbose)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@CLI.arg_annotator
|
|
35
|
+
def print_versions(
|
|
36
|
+
odoo_main_path=CLI.odoo_paths.bin_path,
|
|
37
|
+
):
|
|
38
|
+
"""
|
|
39
|
+
Print gOdoo and Odoo Version info.
|
|
40
|
+
"""
|
|
41
|
+
rich_print(f"gOdoo Version: [bold green]{__version__}[/bold green]")
|
|
42
|
+
odoo_version = odoo_bin_get_version(odoo_main_path)
|
|
43
|
+
rich_print(f"Odoo Version: [bold green]{odoo_version}[/bold green]")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def main_cli():
|
|
47
|
+
load_dotenv(".env", override=True)
|
|
48
|
+
|
|
49
|
+
help_text = "gOdoo CLI for Interacting with Odoo"
|
|
50
|
+
app = typer.Typer(no_args_is_help=True, callback=main_callback, rich_markup_mode="rich", help=help_text)
|
|
51
|
+
# Nested Subcommands
|
|
52
|
+
app.add_typer(
|
|
53
|
+
typer_instance=rpc_cli_app(),
|
|
54
|
+
name="rpc",
|
|
55
|
+
)
|
|
56
|
+
app.add_typer(
|
|
57
|
+
typer_instance=db_cli_app(),
|
|
58
|
+
name="db",
|
|
59
|
+
)
|
|
60
|
+
app.add_typer(
|
|
61
|
+
typer_instance=source_cli_app(),
|
|
62
|
+
name="source",
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# Normal Subcommands
|
|
66
|
+
app.command("version")(print_versions)
|
|
67
|
+
app.command("bootstrap")(bootstrap_odoo)
|
|
68
|
+
app.command("launch")(launch_odoo)
|
|
69
|
+
app.command("launch-import")(launch_import)
|
|
70
|
+
app.command("test")(odoo_test)
|
|
71
|
+
app.command("config")(set_odoo_config)
|
|
72
|
+
app.command("shell")(odoo_shell)
|
|
73
|
+
app.command("uninstall")(uninstall_modules)
|
|
74
|
+
return app
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def launch_cli():
|
|
78
|
+
app = main_cli()
|
|
79
|
+
app()
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
|
|
5
|
+
from typer import Option
|
|
6
|
+
|
|
7
|
+
from .helpers.cli import get_type_from_default, typer_retuner, typer_unpacker
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class OdooLaunchArgs:
|
|
12
|
+
extra_cmd_args: List[str] = Option(None, help="extra agruments to pass to odoo-bin", rich_help_panel="Odoo")
|
|
13
|
+
multithread_worker_count: int = Option(
|
|
14
|
+
5, help="count of worker threads. will enable proxy_mode if >0", rich_help_panel="Odoo"
|
|
15
|
+
)
|
|
16
|
+
languages: str = Option("de_DE,en_US", help="languages to load by default", rich_help_panel="Odoo")
|
|
17
|
+
no_install_base: bool = Option(
|
|
18
|
+
False,
|
|
19
|
+
"--no-install-base",
|
|
20
|
+
help="dont install [bold]base[/bold] and [bold]web[/bold] module",
|
|
21
|
+
rich_help_panel="Odoo",
|
|
22
|
+
)
|
|
23
|
+
no_install_workspace_modules: bool = Option(
|
|
24
|
+
False,
|
|
25
|
+
"--no-install-workspace-modules",
|
|
26
|
+
help="dont automatically install modules found in [bold cyan]--workspace_path[/bold cyan]",
|
|
27
|
+
rich_help_panel="Odoo",
|
|
28
|
+
)
|
|
29
|
+
no_update_source: bool = Option(
|
|
30
|
+
False, "--no-update-source", help="Update Odoo Source and Thirdparty Addons", rich_help_panel="Source Code"
|
|
31
|
+
)
|
|
32
|
+
no_addons_remove_unspecified: bool = Option(
|
|
33
|
+
False,
|
|
34
|
+
"--no-addons-remove-unspecified",
|
|
35
|
+
help="don't remove unspecified addons if not '[bold cyan]--no-update-source[/bold cyan]'",
|
|
36
|
+
rich_help_panel="Source Code",
|
|
37
|
+
)
|
|
38
|
+
odoo_demo: bool = Option(False, "--odoo-demo", help="Load Demo Data", rich_help_panel="Odoo")
|
|
39
|
+
dev_mode: bool = Option(
|
|
40
|
+
False,
|
|
41
|
+
"--dev-mode",
|
|
42
|
+
help="Passes '[bold cyan]--dev xml,qweb,reload[/bold cyan]' to odoo",
|
|
43
|
+
rich_help_panel="Odoo",
|
|
44
|
+
)
|
|
45
|
+
log_file_path: Path = Option(None, dir_okay=False, writable=True, help="Logfile Path", rich_help_panel="Odoo")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass
|
|
49
|
+
class OdooPathCLIArgs:
|
|
50
|
+
bin_path: Path = Option(
|
|
51
|
+
...,
|
|
52
|
+
envvar="ODOO_MAIN_FOLDER",
|
|
53
|
+
help="folder that contains odoo-bin",
|
|
54
|
+
rich_help_panel="Path Options",
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
conf_path: Path = Option(
|
|
58
|
+
...,
|
|
59
|
+
envvar="ODOO_CONF_PATH",
|
|
60
|
+
help="odoo.conf path",
|
|
61
|
+
rich_help_panel="Path Options",
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
workspace_addon_path: Path = Option(
|
|
65
|
+
...,
|
|
66
|
+
envvar="ODOO_WORKSPACE_ADDON_LOCATION",
|
|
67
|
+
help="path to dev workspace addons",
|
|
68
|
+
rich_help_panel="Path Options",
|
|
69
|
+
)
|
|
70
|
+
thirdparty_addon_path: Path = Option(
|
|
71
|
+
...,
|
|
72
|
+
envvar="ODOO_THIRDPARTY_LOCATION",
|
|
73
|
+
help="folder that contains thirdparty repos like OCA",
|
|
74
|
+
rich_help_panel="Path Options",
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
bootstrap_flag_location: Path = Option(
|
|
78
|
+
...,
|
|
79
|
+
envvar="ODOO_BOOTSTRAP_FLAG",
|
|
80
|
+
help="Location of the Bootstrap indicator file",
|
|
81
|
+
rich_help_panel="Path Options",
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@dataclass
|
|
86
|
+
class RpcCLIArgs:
|
|
87
|
+
rpc_host: str = Option(
|
|
88
|
+
...,
|
|
89
|
+
envvar="ODOO_RPC_HOST",
|
|
90
|
+
help="Odoo RPC Host",
|
|
91
|
+
rich_help_panel="RPC Options",
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
rpc_user: str = Option(
|
|
95
|
+
...,
|
|
96
|
+
envvar="ODOO_RPC_USER",
|
|
97
|
+
help="User for RPC login",
|
|
98
|
+
rich_help_panel="RPC Options",
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
rpc_password: str = Option(
|
|
102
|
+
...,
|
|
103
|
+
envvar="ODOO_RPC_PASSWORD",
|
|
104
|
+
help="Password RPC Login Password",
|
|
105
|
+
rich_help_panel="RPC Options",
|
|
106
|
+
)
|
|
107
|
+
rpc_db_name: str = Option(
|
|
108
|
+
...,
|
|
109
|
+
envvar=["ODOO_RPC_DB_NAME", "ODOO_MAIN_DB"],
|
|
110
|
+
help="RPC database name",
|
|
111
|
+
rich_help_panel="RPC Options",
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@dataclass
|
|
116
|
+
class DatabaseCLIArgs:
|
|
117
|
+
db_filter: str = Option(
|
|
118
|
+
...,
|
|
119
|
+
envvar="ODOO_DB_FILTER",
|
|
120
|
+
help="database filter for odoo_conf",
|
|
121
|
+
rich_help_panel="Database Options",
|
|
122
|
+
)
|
|
123
|
+
db_host: str = Option(
|
|
124
|
+
"",
|
|
125
|
+
envvar="ODOO_DB_HOST",
|
|
126
|
+
help="db hostname (empty for default socket)",
|
|
127
|
+
rich_help_panel="Database Options",
|
|
128
|
+
)
|
|
129
|
+
db_name: str = Option(
|
|
130
|
+
...,
|
|
131
|
+
envvar="ODOO_MAIN_DB",
|
|
132
|
+
help="launch database name",
|
|
133
|
+
rich_help_panel="Database Options",
|
|
134
|
+
)
|
|
135
|
+
db_user: str = Option(
|
|
136
|
+
...,
|
|
137
|
+
envvar="ODOO_DB_USER",
|
|
138
|
+
help="db user",
|
|
139
|
+
rich_help_panel="Database Options",
|
|
140
|
+
)
|
|
141
|
+
db_password: str = Option(
|
|
142
|
+
...,
|
|
143
|
+
envvar="ODOO_DB_PASSWORD",
|
|
144
|
+
help="db password",
|
|
145
|
+
rich_help_panel="Database Options",
|
|
146
|
+
)
|
|
147
|
+
db_port: str = Option(
|
|
148
|
+
"",
|
|
149
|
+
envvar="ODOO_DB_PORT",
|
|
150
|
+
help="db host port (empty for socket)",
|
|
151
|
+
rich_help_panel="Database Options",
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@dataclass
|
|
156
|
+
class SourceGetArgs:
|
|
157
|
+
mainfest_path: Path = Option(
|
|
158
|
+
"",
|
|
159
|
+
envvar="ODOO_MANIFEST",
|
|
160
|
+
help="godoo manifest path, when downloading odoo source (skip repo_url)",
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
source_download_archive: Optional[bool] = Option(
|
|
164
|
+
False,
|
|
165
|
+
"--source-download-archive",
|
|
166
|
+
envvar="SOURCE_CLONE_ARCHIVE",
|
|
167
|
+
help="When using a HTTPs Repo Url for Github we can download a snapshop without the Repo history",
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
class CommonCLI:
|
|
172
|
+
def __init__(self) -> None:
|
|
173
|
+
self.odoo_paths = OdooPathCLIArgs()
|
|
174
|
+
self.odoo_launch = OdooLaunchArgs()
|
|
175
|
+
self.database = DatabaseCLIArgs()
|
|
176
|
+
self.rpc = RpcCLIArgs()
|
|
177
|
+
self.source = SourceGetArgs
|
|
178
|
+
self.returner = typer_retuner
|
|
179
|
+
self.unpacker = typer_unpacker
|
|
180
|
+
|
|
181
|
+
@property
|
|
182
|
+
def arg_annotator(self):
|
|
183
|
+
"""Add type annotations for
|
|
184
|
+
|
|
185
|
+
Returns
|
|
186
|
+
-------
|
|
187
|
+
Callback
|
|
188
|
+
Annotator function with CommonCLI Props as arguments
|
|
189
|
+
"""
|
|
190
|
+
my_args = self.__dict__
|
|
191
|
+
return get_type_from_default(*list(my_args.values()))
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from .bootstrap import bootstrap_odoo
|
|
2
2
|
from .config import set_odoo_config
|
|
3
|
-
from .
|
|
3
|
+
from .db import db_cli_app
|
|
4
|
+
from .launch import launch_import, launch_odoo
|
|
4
5
|
from .rpc import rpc_cli_app
|
|
5
6
|
from .shell import odoo_shell, uninstall_modules
|
|
6
|
-
from .source_get import
|
|
7
|
+
from .source_get import source_cli_app
|
|
7
8
|
from .test import odoo_test
|
|
@@ -3,13 +3,12 @@ import re
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from typing import List
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
|
|
6
|
+
from ..cli_common import CommonCLI
|
|
8
7
|
from ..helpers.bootstrap import _install_py_reqs_by_odoo_cmd
|
|
9
|
-
from ..helpers.cli import typer_retuner, typer_unpacker
|
|
10
8
|
from ..helpers.odoo_files import get_addon_paths, get_odoo_module_paths
|
|
11
9
|
from ..helpers.system import run_cmd
|
|
12
|
-
|
|
10
|
+
|
|
11
|
+
CLI = CommonCLI()
|
|
13
12
|
|
|
14
13
|
LOGGER = logging.getLogger(__name__)
|
|
15
14
|
|
|
@@ -44,10 +43,10 @@ def _boostrap_command(
|
|
|
44
43
|
odoo bin --addons-path
|
|
45
44
|
workspace_addon_path : Path
|
|
46
45
|
path to addons in dev repo
|
|
47
|
-
db_host : str
|
|
48
|
-
db hostname for odoo.conf
|
|
49
46
|
db_filter : str
|
|
50
47
|
db filter for odoo.conf
|
|
48
|
+
db_host : str
|
|
49
|
+
db hostname for odoo.conf
|
|
51
50
|
db_name : str
|
|
52
51
|
database name for odoo.conf
|
|
53
52
|
db_user : str
|
|
@@ -125,82 +124,38 @@ def _boostrap_command(
|
|
|
125
124
|
return " ".join(odoo_cmd)
|
|
126
125
|
|
|
127
126
|
|
|
128
|
-
@
|
|
127
|
+
@CLI.unpacker
|
|
128
|
+
@CLI.arg_annotator
|
|
129
129
|
def bootstrap_odoo(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
db_host
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
rich_help_panel="Database Options",
|
|
147
|
-
),
|
|
148
|
-
db_name: str = typer.Option(
|
|
149
|
-
...,
|
|
150
|
-
envvar="ODOO_MAIN_DB",
|
|
151
|
-
help="launch database name",
|
|
152
|
-
rich_help_panel="Database Options",
|
|
153
|
-
),
|
|
154
|
-
db_user: str = typer.Option(
|
|
155
|
-
...,
|
|
156
|
-
envvar="ODOO_DB_USER",
|
|
157
|
-
help="db user",
|
|
158
|
-
rich_help_panel="Database Options",
|
|
159
|
-
),
|
|
160
|
-
db_password: str = typer.Option(
|
|
161
|
-
...,
|
|
162
|
-
envvar="ODOO_DB_PASSWORD",
|
|
163
|
-
help="db password",
|
|
164
|
-
rich_help_panel="Database Options",
|
|
165
|
-
),
|
|
166
|
-
db_port: str = typer.Option(
|
|
167
|
-
"",
|
|
168
|
-
envvar="ODOO_DB_PORT",
|
|
169
|
-
help="db host port (empty for socket)",
|
|
170
|
-
rich_help_panel="Database Options",
|
|
171
|
-
),
|
|
172
|
-
extra_cmd_args: List[str] = typer.Option(None, help="extra agruments to pass to odoo-bin"),
|
|
173
|
-
multithread_worker_count: int = typer.Option(5, help="count of worker threads. will enable proxy_mode if >0"),
|
|
174
|
-
languages: str = typer.Option("de_DE,en_US", help="languages to load by default"),
|
|
175
|
-
no_install_base: bool = typer.Option(
|
|
176
|
-
False, "--no-install-base", help="dont install [bold]base[/bold] and [bold]web[/bold] module"
|
|
177
|
-
),
|
|
178
|
-
no_install_workspace_modules: bool = typer.Option(
|
|
179
|
-
False,
|
|
180
|
-
"--no-install-workspace-modules",
|
|
181
|
-
help="dont automatically install modules found in [bold cyan]--workspace_path[/bold cyan]",
|
|
182
|
-
),
|
|
183
|
-
no_update_source: bool = typer.Option(False, "--no-update-source", help="Update Odoo Source and Thirdparty Addons"),
|
|
184
|
-
no_addons_remove_unspecified: bool = typer.Option(
|
|
185
|
-
False,
|
|
186
|
-
"--no-addons-remove-unspecified",
|
|
187
|
-
help="don't remove unspecified addons if not '[bold cyan]--no-update-source[/bold cyan]'",
|
|
188
|
-
),
|
|
130
|
+
odoo_main_path=CLI.odoo_paths.bin_path,
|
|
131
|
+
workspace_addon_path=CLI.odoo_paths.workspace_addon_path,
|
|
132
|
+
thirdparty_addon_path=CLI.odoo_paths.thirdparty_addon_path,
|
|
133
|
+
odoo_conf_path=CLI.odoo_paths.conf_path,
|
|
134
|
+
bootstrap_flag_location=CLI.odoo_paths.bootstrap_flag_location,
|
|
135
|
+
db_filter=CLI.database.db_filter,
|
|
136
|
+
db_host=CLI.database.db_host,
|
|
137
|
+
db_port=CLI.database.db_port,
|
|
138
|
+
db_name=CLI.database.db_name,
|
|
139
|
+
db_user=CLI.database.db_user,
|
|
140
|
+
db_password=CLI.database.db_password,
|
|
141
|
+
extra_cmd_args=CLI.odoo_launch.extra_cmd_args,
|
|
142
|
+
multithread_worker_count=CLI.odoo_launch.multithread_worker_count,
|
|
143
|
+
languages=CLI.odoo_launch.languages,
|
|
144
|
+
no_install_base=CLI.odoo_launch.no_install_base,
|
|
145
|
+
no_install_workspace_modules=CLI.odoo_launch.no_install_workspace_modules,
|
|
189
146
|
):
|
|
190
147
|
"""Bootstrap Odoo."""
|
|
191
|
-
if not no_update_source:
|
|
192
|
-
get_source(ctx=ctx, remove_unspecified_addons=not no_addons_remove_unspecified)
|
|
193
148
|
|
|
194
149
|
addon_paths = get_addon_paths(
|
|
195
|
-
odoo_main_repo=
|
|
196
|
-
workspace_addon_path=
|
|
150
|
+
odoo_main_repo=odoo_main_path,
|
|
151
|
+
workspace_addon_path=workspace_addon_path,
|
|
197
152
|
thirdparty_addon_path=thirdparty_addon_path,
|
|
198
153
|
)
|
|
199
154
|
|
|
200
155
|
cmd_string = _boostrap_command(
|
|
201
|
-
odoo_main_path=
|
|
202
|
-
odoo_conf_path=
|
|
203
|
-
workspace_addon_path=
|
|
156
|
+
odoo_main_path=odoo_main_path,
|
|
157
|
+
odoo_conf_path=odoo_conf_path,
|
|
158
|
+
workspace_addon_path=workspace_addon_path,
|
|
204
159
|
addon_paths=addon_paths,
|
|
205
160
|
db_host=db_host,
|
|
206
161
|
db_name=db_name,
|
|
@@ -221,7 +176,7 @@ def bootstrap_odoo(
|
|
|
221
176
|
LOGGER.info("Launching Bootstrap Commandline")
|
|
222
177
|
ret = run_cmd(cmd_string).returncode
|
|
223
178
|
if ret == 0:
|
|
224
|
-
|
|
179
|
+
bootstrap_flag_location.touch()
|
|
225
180
|
else:
|
|
226
181
|
LOGGER.error("Odoo-Bin Returned %d", ret)
|
|
227
|
-
return
|
|
182
|
+
return CLI.returner(ret)
|
|
@@ -8,20 +8,22 @@ from typing import List
|
|
|
8
8
|
|
|
9
9
|
import typer
|
|
10
10
|
|
|
11
|
-
from ..
|
|
11
|
+
from ..cli_common import CommonCLI
|
|
12
12
|
|
|
13
|
+
CLI = CommonCLI()
|
|
13
14
|
LOGGER = logging.getLogger(__name__)
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
@
|
|
17
|
+
@CLI.unpacker
|
|
18
|
+
@CLI.arg_annotator
|
|
17
19
|
def set_odoo_config(
|
|
18
|
-
ctx: typer.Context,
|
|
19
20
|
options: List[str] = typer.Argument(..., help="odoo.conf options by key=value"),
|
|
21
|
+
odoo_conf_path=CLI.odoo_paths.conf_path,
|
|
20
22
|
):
|
|
21
23
|
"""
|
|
22
24
|
Set odoo.conf values.
|
|
23
25
|
"""
|
|
24
|
-
conf_path = Path(
|
|
26
|
+
conf_path = Path(odoo_conf_path)
|
|
25
27
|
odoo_conf = ConfigParser()
|
|
26
28
|
odoo_conf.read(conf_path)
|
|
27
29
|
LOGGER.info("Setting Odoo Conf Options for Stage")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .cli import db_cli_app
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from contextlib import contextmanager
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
import psycopg2
|
|
6
|
+
|
|
7
|
+
LOGGER = logging.getLogger(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class DBConnection:
|
|
12
|
+
db_name: str
|
|
13
|
+
hostname: str
|
|
14
|
+
username: str
|
|
15
|
+
password: str
|
|
16
|
+
port: int = 0
|
|
17
|
+
conn_timeout: int = 5
|
|
18
|
+
|
|
19
|
+
def get_connection(self):
|
|
20
|
+
LOGGER.debug(
|
|
21
|
+
"Connecting to DB: '%s:%s' U='%s' P='%s' D='%s'",
|
|
22
|
+
self.hostname,
|
|
23
|
+
self.port,
|
|
24
|
+
self.username,
|
|
25
|
+
self.password,
|
|
26
|
+
self.db_name,
|
|
27
|
+
)
|
|
28
|
+
return psycopg2.connect(
|
|
29
|
+
host=self.hostname,
|
|
30
|
+
port=self.port or None,
|
|
31
|
+
user=self.username,
|
|
32
|
+
password=self.password,
|
|
33
|
+
dbname=self.db_name,
|
|
34
|
+
connect_timeout=self.conn_timeout,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
@contextmanager
|
|
38
|
+
def connect(self):
|
|
39
|
+
connection = self.get_connection()
|
|
40
|
+
cr = connection.cursor()
|
|
41
|
+
try:
|
|
42
|
+
yield cr
|
|
43
|
+
LOGGER.debug("Committing DB cursor")
|
|
44
|
+
connection.commit()
|
|
45
|
+
except Exception as e:
|
|
46
|
+
LOGGER.warning("Rolling Back DB cursor. Got Exception: %s", e)
|
|
47
|
+
connection.rollback()
|
|
48
|
+
finally:
|
|
49
|
+
LOGGER.debug("Closing DB connection")
|
|
50
|
+
cr.close()
|
|
51
|
+
connection.close()
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
from passlib.context import CryptContext
|
|
5
|
+
|
|
6
|
+
from ...cli_common import CommonCLI
|
|
7
|
+
from ...helpers.cli import check_dangerous_command
|
|
8
|
+
from .connection import DBConnection
|
|
9
|
+
|
|
10
|
+
LOGGER = logging.getLogger(__name__)
|
|
11
|
+
CLI = CommonCLI()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _hash_odoo_password(password: str) -> str:
|
|
15
|
+
"""Hash Password for Odoo
|
|
16
|
+
|
|
17
|
+
Parameters
|
|
18
|
+
----------
|
|
19
|
+
password : str
|
|
20
|
+
Password to hash
|
|
21
|
+
|
|
22
|
+
Returns
|
|
23
|
+
-------
|
|
24
|
+
str
|
|
25
|
+
Hashed Password
|
|
26
|
+
"""
|
|
27
|
+
return CryptContext(schemes=["pbkdf2_sha512", "md5_crypt"]).encrypt(password)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@CLI.arg_annotator
|
|
31
|
+
def set_passwords(
|
|
32
|
+
new_password: str = typer.Argument(..., help="Password to set for all users"),
|
|
33
|
+
db_host=CLI.database.db_host,
|
|
34
|
+
db_port=CLI.database.db_port,
|
|
35
|
+
db_name=CLI.database.db_name,
|
|
36
|
+
db_user=CLI.database.db_user,
|
|
37
|
+
db_password=CLI.database.db_password,
|
|
38
|
+
):
|
|
39
|
+
"""Set Login Password for all Users."""
|
|
40
|
+
|
|
41
|
+
check_dangerous_command()
|
|
42
|
+
|
|
43
|
+
connection = DBConnection(
|
|
44
|
+
hostname=db_host,
|
|
45
|
+
port=db_port,
|
|
46
|
+
username=db_user,
|
|
47
|
+
password=db_password,
|
|
48
|
+
db_name=db_name,
|
|
49
|
+
)
|
|
50
|
+
hashed_pw = _hash_odoo_password(new_password)
|
|
51
|
+
with connection.connect() as conn:
|
|
52
|
+
conn.execute(f"UPDATE res_users SET password='{hashed_pw}'")
|
|
53
|
+
LOGGER.info("Password for all users set to: '%s'", new_password)
|