gOdoo-cli 0.1.2__tar.gz → 0.1.4__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.
Files changed (31) hide show
  1. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/PKG-INFO +4 -1
  2. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/pyproject.toml +6 -1
  3. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/setup.py +2 -2
  4. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/__init__.py +1 -1
  5. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/commands/bootstrap.py +64 -16
  6. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/commands/launch.py +10 -45
  7. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/commands/rpc/translations.py +2 -2
  8. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/commands/shell.py +3 -3
  9. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/commands/test.py +2 -2
  10. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/helpers/__init__.py +19 -0
  11. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/helpers/odoo_files.py +52 -13
  12. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/LICENSE +0 -0
  13. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/README.md +0 -0
  14. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/__main__.py +0 -0
  15. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/cli.py +0 -0
  16. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/commands/__init__.py +0 -0
  17. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/commands/makedev.py +0 -0
  18. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/commands/rpc/__init__.py +0 -0
  19. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/commands/rpc/cli.py +0 -0
  20. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/commands/rpc/cli_callbacks.py +0 -0
  21. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/commands/rpc/importer.py +0 -0
  22. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/commands/rpc/modules.py +0 -0
  23. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/commands/source_get.py +0 -0
  24. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/git/__init__.py +0 -0
  25. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/git/git_odoo.py +0 -0
  26. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/git/git_odoo_addons.py +0 -0
  27. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/git/git_repo.py +0 -0
  28. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/git/git_url.py +0 -0
  29. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/git/zip_download.py +0 -0
  30. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/helpers/cli.py +0 -0
  31. {godoo_cli-0.1.2 → godoo_cli-0.1.4}/src/godoo_cli/helpers/odoo_manifest.py +0 -0
@@ -1,8 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: godoo-cli
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: Wrapper around Odoo-Bin with some convinience RPC functions.
5
+ Home-page: https://github.com/OpenJKSoftware/gOdoo
5
6
  License: LGPL-3
7
+ Keywords: odoo,godoo,devcontainer
6
8
  Author: Joshua Kreuder
7
9
  Author-email: Joshua_Kreuder@outlook.com
8
10
  Requires-Python: >=3.8,<3.11
@@ -30,6 +32,7 @@ Requires-Dist: rope (==0.23.0); extra == "devcontainer"
30
32
  Requires-Dist: ruamel-yaml (==0.17.21)
31
33
  Requires-Dist: typer[all] (>=0.7.0,<0.8.0)
32
34
  Requires-Dist: watchdog (==2.1.7); extra == "devcontainer"
35
+ Project-URL: Repository, https://github.com/OpenJKSoftware/gOdoo
33
36
  Description-Content-Type: text/markdown
34
37
 
35
38
  # gOdoo Dev Environment
@@ -1,11 +1,13 @@
1
1
  [tool.poetry]
2
2
  name = "gOdoo-cli"
3
- version = "0.1.2"
3
+ version = "0.1.4"
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"
7
7
  readme = "README.md"
8
8
  packages = [{include = "godoo_cli", from = "src"}]
9
+ repository = "https://github.com/OpenJKSoftware/gOdoo"
10
+ keywords = ["odoo", "godoo","devcontainer"]
9
11
 
10
12
  [tool.poetry_bumpversion.file."src/godoo_cli/__init__.py"]
11
13
 
@@ -53,6 +55,9 @@ codequality = [
53
55
  requires = ["poetry-core>=1.0.0"]
54
56
  build-backend = "poetry.core.masonry.api"
55
57
 
58
+ [tool.pyright]
59
+ ignore="**/__manifest__.py"
60
+
56
61
  [tool.black]
57
62
  line-length = 120
58
63
 
@@ -40,14 +40,14 @@ entry_points = \
40
40
 
41
41
  setup_kwargs = {
42
42
  'name': 'godoo-cli',
43
- 'version': '0.1.2',
43
+ 'version': '0.1.4',
44
44
  'description': 'Wrapper around Odoo-Bin with some convinience RPC functions.',
45
45
  'long_description': '# gOdoo Dev Environment\n\n![OdooLogo](https://raw.githubusercontent.com/OpenJKSoftware/gOdoo/main/assets/odoo_logo.png)\n![ComposeLogo](https://raw.githubusercontent.com/docker/compose/v2/logo.png)\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 enterprise` -> godoo launch with `-i web_enterprise` parameter\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',
46
46
  'author': 'Joshua Kreuder',
47
47
  'author_email': 'Joshua_Kreuder@outlook.com',
48
48
  'maintainer': 'None',
49
49
  'maintainer_email': 'None',
50
- 'url': 'None',
50
+ 'url': 'https://github.com/OpenJKSoftware/gOdoo',
51
51
  'package_dir': package_dir,
52
52
  'packages': packages,
53
53
  'package_data': package_data,
@@ -1,2 +1,2 @@
1
- __version__ = "0.1.2"
1
+ __version__ = "0.1.4"
2
2
  from .cli import launch_cli
@@ -1,21 +1,64 @@
1
1
  import logging
2
- import os
2
+ import re
3
3
  from pathlib import Path
4
4
  from typing import List
5
5
 
6
6
  import typer
7
7
 
8
+ from ..helpers import run_cmd
8
9
  from ..helpers.cli import typer_retuner, typer_unpacker
9
- from ..helpers.odoo_files import get_addon_paths, get_odoo_addons_in_folder
10
+ from ..helpers.odoo_files import _get_python_requirements_of_modules, get_addon_paths, get_odoo_module_paths
10
11
  from .source_get import get_source
11
12
 
12
13
  LOGGER = logging.getLogger(__name__)
13
14
 
14
15
 
16
+ def _install_py_reqs_for_modules(addon_paths: List[Path], module_names: List[str] = None):
17
+ """Install Python Requirements mentioned in odoo module manifests of given modules
18
+
19
+ Parameters
20
+ ----------
21
+ addon_paths : List[Path]
22
+ odoo-bin addons path
23
+ module_names : List[str], Optional
24
+ List of modules to filter for, by default "all available modules"
25
+
26
+ Returns
27
+ -------
28
+ CompletedProcess
29
+ """
30
+ py_reqs = _get_python_requirements_of_modules(addon_paths=addon_paths, filter_module_names=module_names)
31
+ if py_reqs:
32
+ LOGGER.info("Installing Python requirements: %s", ", ".join(py_reqs))
33
+ return run_cmd(f"pip install {' '.join(py_reqs)}")
34
+ LOGGER.debug("No py Requirements to be installed")
35
+
36
+
37
+ def _install_py_reqs_by_odoo_cmd(addon_paths: List[Path], odoo_bin_cmd: str):
38
+ """Install Python reqs for modules mentioned in odoo-bin commandline --init or -i directives.
39
+
40
+ Parameters
41
+ ----------
42
+ addon_paths : List[Path]
43
+ odoo-bin addons-path
44
+ odoo_bin_cmd : str
45
+ odoo-bin commandline
46
+
47
+ Returns
48
+ -------
49
+ CompletedProcess
50
+ """
51
+ install_modules = []
52
+ for m in re.finditer(r'(--init|-i) "?([^ \n]+)"?', odoo_bin_cmd):
53
+ install_modules += m.group(2).split(",")
54
+ if install_modules:
55
+ return _install_py_reqs_for_modules(addon_paths=addon_paths, module_names=install_modules)
56
+
57
+
15
58
  def _boostrap_command(
16
59
  odoo_main_path: Path,
17
60
  odoo_conf_path: Path,
18
- thirdparty_addon_path: Path,
61
+ addon_paths: List[Path],
19
62
  workspace_addon_path: Path,
20
63
  db_host: str,
21
64
  db_filter: str,
@@ -38,8 +81,8 @@ def _boostrap_command(
38
81
  folder with odoo-bin
39
82
  odoo_conf_path : Path
40
83
  path to odoo.conf
41
- thirdparty_addon_path : Path
42
- path that contains thirdparty addon repo folders
84
+ addon_paths : List[Path]
85
+ odoo bin --addons-path
43
86
  workspace_addon_path : Path
44
87
  path to addons in dev repo
45
88
  db_host : str
@@ -85,8 +128,8 @@ def _boostrap_command(
85
128
 
86
129
  LOGGER.info("Getting Addon Paths")
87
130
 
88
- workspace_addons = get_odoo_addons_in_folder(workspace_addon_path)
89
- if any(["-i" in i or "--init" in i for i in extra_cmd_args]):
131
+ workspace_addons = get_odoo_module_paths(workspace_addon_path)
132
+ if any([re.match(r"( |^)(-i|--init)", i) for i in extra_cmd_args]):
90
133
  init_modules = []
91
134
  else:
92
135
  init_modules = ["base", "web"] if install_base else []
@@ -94,12 +137,6 @@ def _boostrap_command(
94
137
  init_modules += [f.name for f in workspace_addons]
95
138
  init_cmd = "--init " + ",".join(init_modules) if init_modules else ""
96
139
 
97
- addon_paths = get_addon_paths(
98
- odoo_main_repo=odoo_main_path,
99
- workspace_addon_path=workspace_addon_path,
100
- zip_addon_path=thirdparty_addon_path / "custom", # !Todo Pull out into variable
101
- thirdparty_addon_path=thirdparty_addon_path,
102
- )
103
140
  addon_paths = [str(p.absolute()) for p in addon_paths]
104
141
  addon_paths = ", ".join(list(filter(None, addon_paths)))
105
142
 
@@ -155,11 +192,18 @@ def bootstrap_odoo(
155
192
  if update_source:
156
193
  get_source(ctx=ctx, remove_unspecified_addons=addons_remove_unspecified)
157
194
 
195
+ addon_paths = get_addon_paths(
196
+ odoo_main_repo=ctx.obj.odoo_main_path,
197
+ workspace_addon_path=ctx.obj.workspace_addon_path,
198
+ zip_addon_path=thirdparty_addon_path / "custom", # !Todo Pull out into variable
199
+ thirdparty_addon_path=thirdparty_addon_path,
200
+ )
201
+
158
202
  cmd_string = _boostrap_command(
159
203
  odoo_main_path=ctx.obj.odoo_main_path,
160
204
  odoo_conf_path=ctx.obj.odoo_conf_path,
161
- thirdparty_addon_path=thirdparty_addon_path,
162
205
  workspace_addon_path=ctx.obj.workspace_addon_path,
206
+ addon_paths=addon_paths,
163
207
  db_host=db_host,
164
208
  db_name=db_name,
165
209
  db_filter=db_filter,
@@ -172,8 +216,12 @@ def bootstrap_odoo(
172
216
  multithread_worker_count=multithread_worker_count,
173
217
  languages=languages,
174
218
  )
175
- LOGGER.info('Launching Bootstrap Commandline: "%s"', cmd_string)
176
- ret = os.system(cmd_string)
219
+
220
+ if update_source:
221
+ _install_py_reqs_by_odoo_cmd(addon_paths=addon_paths, odoo_bin_cmd=cmd_string)
222
+
223
+ LOGGER.info("Launching Bootstrap Commandline")
224
+ ret = run_cmd(cmd_string).returncode
177
225
  if ret == 0:
178
226
  ctx.obj.bootstrap_flag_location.touch()
179
227
  else:
@@ -1,5 +1,4 @@
1
1
  import logging
2
- import os
3
2
  import threading
4
3
  from pathlib import Path
5
4
  from typing import List
@@ -7,8 +6,9 @@ from typing import List
7
6
  import typer
8
7
 
9
8
  from ..commands.rpc.cli import rpc_callback
9
+ from ..helpers import run_cmd
10
10
  from ..helpers.cli import typer_retuner, typer_unpacker
11
- from ..helpers.odoo_files import get_odoo_addons_in_folder
11
+ from ..helpers.odoo_files import get_odoo_module_paths
12
12
  from .bootstrap import bootstrap_odoo
13
13
  from .makedev import makedev_config, makedev_rpc
14
14
  from .rpc import import_to_odoo
@@ -38,9 +38,7 @@ def _launch_command(
38
38
  upgrade_workspace_modules : bool, optional
39
39
  upgrade workspace addons, by default True
40
40
  """
41
- upgrade_addons = (
42
- [f.name for f in get_odoo_addons_in_folder(workspace_addon_path)] if upgrade_workspace_modules else []
43
- )
41
+ upgrade_addons = [f.name for f in get_odoo_module_paths(workspace_addon_path)] if upgrade_workspace_modules else []
44
42
  if any(["-u" in i or "--update" in i for i in extra_cmd_args]):
45
43
  upgrade_addons = []
46
44
  update_addon_string = "--update " + ",".join(upgrade_addons) if upgrade_addons else ""
@@ -54,39 +52,6 @@ def _launch_command(
54
52
  return " ".join(odoo_cmd)
55
53
 
56
54
 
57
- def _launch(
58
- odoo_path: Path,
59
- odoo_conf_path: Path,
60
- extra_cmd_args: List[str],
61
- workspace_addon_path: Path,
62
- upgrade_workspace_modules: bool = True,
63
- ):
64
- """Launches Odoo
65
-
66
- Parameters
67
- ----------
68
- odoo_path : Path
69
- Path to odoo-bin folder
70
- odoo_conf_path : Path
71
- Path to odoo.conf
72
- extra_cmd_args : List[str]
73
- extra args to pass to odoo-bin
74
- workspace_addon_path : Path
75
- Path to dev workspace addons folder
76
- upgrade_workspace_modules : bool, optional
77
- upgrade workspace addons, by default True
78
- """
79
- cmd_string = _launch_command(
80
- odoo_path=odoo_path,
81
- odoo_conf_path=odoo_conf_path,
82
- extra_cmd_args=extra_cmd_args,
83
- workspace_addon_path=workspace_addon_path,
84
- upgrade_workspace_modules=upgrade_workspace_modules,
85
- )
86
- LOGGER.info("Launching Odoo: '%s'", cmd_string)
87
- return os.system(cmd_string)
88
-
89
-
90
55
  @typer_unpacker
91
56
  def launch_odoo(
92
57
  ctx: typer.Context,
@@ -116,20 +81,19 @@ def launch_odoo(
116
81
 
117
82
  if ctx.obj.odoo_conf_path.exists() and prep_stage:
118
83
  makedev_config(ctx)
119
-
120
84
  LOGGER.info("Bootstrap Flag Status: %s", ctx.obj.bootstrap_flag_location.exists())
121
85
  bootstraped = False
122
86
  ret = ""
123
87
  if not ctx.obj.bootstrap_flag_location.exists():
124
- extra_odoo_args_bootstrap = extra_odoo_args.copy()
88
+ _extra_bootstrap_args = extra_odoo_args.copy()
125
89
  if ea := extra_bootstrap_args:
126
- extra_odoo_args_bootstrap += ea
90
+ _extra_bootstrap_args += ea
127
91
  if not odoo_demo:
128
- extra_odoo_args_bootstrap += ["--without-demo all"]
92
+ _extra_bootstrap_args += ["--without-demo all"]
129
93
 
130
94
  ret = bootstrap_odoo(
131
95
  ctx=ctx,
132
- extra_cmd_args=extra_odoo_args_bootstrap,
96
+ extra_cmd_args=_extra_bootstrap_args,
133
97
  install_base=install_modules,
134
98
  install_workspace_modules=install_workspace_addons and install_modules,
135
99
  multithread_worker_count=multithread_worker_count,
@@ -172,14 +136,15 @@ def launch_odoo(
172
136
  )
173
137
  loader_thread.start()
174
138
 
175
- ret = _launch(
139
+ cmd_string = _launch_command(
176
140
  odoo_path=ctx.obj.odoo_main_path,
177
141
  odoo_conf_path=ctx.obj.odoo_conf_path,
178
142
  extra_cmd_args=extra_odoo_args,
179
143
  workspace_addon_path=ctx.obj.workspace_addon_path,
180
144
  upgrade_workspace_modules=install_workspace_addons,
181
145
  )
182
- return typer_retuner(ret)
146
+ LOGGER.info("Launching Odoo")
147
+ return typer_retuner(run_cmd(cmd_string).returncode)
183
148
 
184
149
 
185
150
  def launch_cli_app():
@@ -6,7 +6,7 @@ import typer
6
6
  from godoo_rpc.login import wait_for_odoo
7
7
 
8
8
  from ...helpers.cli import typer_retuner
9
- from ...helpers.odoo_files import get_odoo_addons_in_folder
9
+ from ...helpers.odoo_files import get_odoo_module_paths
10
10
  from .cli import rpc_callback
11
11
  from .modules import rpc_get_modules
12
12
 
@@ -71,7 +71,7 @@ def dump_translations(
71
71
  ):
72
72
 
73
73
  addon_path = ctx.obj.workspace_addon_path
74
- addon_folders = get_odoo_addons_in_folder(addon_path)
74
+ addon_folders = get_odoo_module_paths(addon_path)
75
75
  valid_module_names = [str(p.stem) for p in addon_folders]
76
76
  LOGGER.debug("Found modules:\n%s", "\n".join(["\t" + mn for mn in valid_module_names]))
77
77
 
@@ -1,9 +1,9 @@
1
1
  import logging
2
- import os
3
2
  from typing import List
4
3
 
5
4
  import typer
6
5
 
6
+ from ..helpers import run_cmd
7
7
  from ..helpers.cli import typer_retuner, typer_unpacker
8
8
 
9
9
  LOGGER = logging.getLogger(__name__)
@@ -21,7 +21,7 @@ def uninstall_modules(
21
21
  uninstall_cmd = f"env['ir.module.module'].search([('name','in',{module_list_str})]).filtered(lambda m: m.state not in ['uninstallable','uninstalled']).button_immediate_uninstall()"
22
22
  uninstall_shell = f'echo "{uninstall_cmd}" | {str(ctx.obj.odoo_main_path.absolute())}/odoo-bin shell -c {str(ctx.obj.odoo_conf_path.absolute())} --no-http'
23
23
  LOGGER.info("Launching Uninstaller: '%s'", uninstall_shell)
24
- ret = os.system(uninstall_shell)
24
+ ret = run_cmd(uninstall_shell).returncode
25
25
  return typer_retuner(ret)
26
26
 
27
27
 
@@ -39,4 +39,4 @@ def odoo_shell(
39
39
  if pipe_in_command:
40
40
  shell_cmd = f'echo "{pipe_in_command}" |' + shell_cmd
41
41
  LOGGER.debug("Running Command: %s", shell_cmd)
42
- os.system(shell_cmd)
42
+ return typer_retuner(run_cmd(shell_cmd).returncode)
@@ -6,7 +6,7 @@ from typing import List
6
6
  import typer
7
7
 
8
8
  from ..helpers.cli import typer_retuner
9
- from ..helpers.odoo_files import get_changed_modules, get_depends_of_modules, get_odoo_addons_in_folder
9
+ from ..helpers.odoo_files import get_changed_modules, get_depends_of_modules, get_odoo_module_paths
10
10
  from .launch import launch_odoo as launch_odoo
11
11
 
12
12
  LOGGER = logging.getLogger(__name__)
@@ -17,7 +17,7 @@ def _test_modules_special_cases(in_modules: List[str], workspace_addon_path: Pat
17
17
  command = in_modules[0]
18
18
  out_modules = []
19
19
  if command == "all":
20
- out_modules = get_odoo_addons_in_folder(workspace_addon_path)
20
+ out_modules = get_odoo_module_paths(workspace_addon_path)
21
21
 
22
22
  if re_match := re.match(r"changes\:(.*)", command):
23
23
  compare_branch = re_match.group(1)
@@ -2,6 +2,7 @@
2
2
 
3
3
  import logging
4
4
  import os
5
+ import subprocess
5
6
  import sys
6
7
  from pathlib import Path
7
8
 
@@ -11,6 +12,24 @@ from rich.logging import RichHandler
11
12
  LOGGER = logging.getLogger(__name__)
12
13
 
13
14
 
15
+ def run_cmd(command: str) -> subprocess.CompletedProcess:
16
+ """Runs command via subprocess
17
+
18
+ Parameters
19
+ ----------
20
+ command : str
21
+ _description_
22
+
23
+ Returns
24
+ -------
25
+ _type_
26
+ _description_
27
+ """
28
+ LOGGER.debug("Launching Commandline: '%s'", command)
29
+ proc = subprocess.run(command, shell=True)
30
+ return proc
31
+
32
+
14
33
  def ensure_dotenv(varname: str) -> str:
15
34
  """
16
35
  Load Env Var.
@@ -2,32 +2,36 @@
2
2
  import logging
3
3
  from ast import literal_eval
4
4
  from pathlib import Path
5
- from typing import List
5
+ from typing import List, Union
6
6
 
7
7
  from git import Repo
8
8
 
9
9
  LOGGER = logging.getLogger(__name__)
10
10
 
11
11
 
12
- def get_odoo_addons_in_folder(search_folder: Path) -> List[Path]:
13
- """List all Valid odoo module names in the Workspace addon folder.
12
+ def get_odoo_module_paths(search_folders: Union[List[Path], Path]) -> List[Path]:
13
+ """List all Valid odoo module names in one or many Odoo addons folder.
14
14
 
15
15
  Parameters
16
16
  ----------
17
- search_folder : Path
18
- Folder to search in.
17
+ search_folders : Path
18
+ Folder(s) to search in.
19
19
 
20
20
  Returns
21
21
  -------
22
22
  List[Path]
23
23
  List of Valid Module Folders within search_folder
24
24
  """
25
+ if not isinstance(search_folders, List):
26
+ search_folders = [search_folders]
27
+
25
28
  module_paths = []
26
- if not search_folder.exists():
27
- return
28
- for folder in search_folder.iterdir():
29
- if folder.is_dir() and any(folder.glob("__manifest__.py")):
30
- module_paths.append(folder)
29
+ for folder in search_folders:
30
+ if not folder.exists():
31
+ return
32
+ for folder in folder.iterdir():
33
+ if folder.is_dir() and any(folder.glob("__manifest__.py")):
34
+ module_paths.append(folder)
31
35
  return module_paths
32
36
 
33
37
 
@@ -82,7 +86,7 @@ def get_depends_of_modules(addon_path: Path, in_module_paths: List[Path]) -> Lis
82
86
  List[Path]
83
87
  Union of in_module_paths and all their downstream depends.
84
88
  """
85
- all_modules = get_odoo_addons_in_folder(addon_path)
89
+ all_modules = get_odoo_module_paths(addon_path)
86
90
  if not in_module_paths:
87
91
  return
88
92
  added = True
@@ -130,12 +134,47 @@ def get_addon_paths(
130
134
  List of valid addon Paths
131
135
  """
132
136
  odoo_addon_paths = [odoo_main_repo / "addons"]
133
- if get_odoo_addons_in_folder(workspace_addon_path):
137
+ if get_odoo_module_paths(workspace_addon_path):
134
138
  odoo_addon_paths.append(workspace_addon_path)
135
- zip_addon_repos = [f for f in zip_addon_path.iterdir() if f.is_dir() and get_odoo_addons_in_folder(f)]
139
+ zip_addon_repos = [f for f in zip_addon_path.iterdir() if f.is_dir() and get_odoo_module_paths(f)]
136
140
  odoo_addon_paths += zip_addon_repos
137
141
  git_thirdparty_addon_repos = [
138
142
  p for p in thirdparty_addon_path.iterdir() if p.is_dir() and not p.resolve() == zip_addon_path.resolve()
139
143
  ]
140
144
  odoo_addon_paths += git_thirdparty_addon_repos
141
145
  return odoo_addon_paths
146
+
147
+
148
+ def _get_python_requirements_of_modules(addon_paths: List[Path], filter_module_names: List[str] = None):
149
+ """Install python requirements mentioned in module manifests
150
+
151
+ Parameters
152
+ ----------
153
+ addon_paths : List[Path]
154
+ Paths to look for addons. (same as odoo-bin)
155
+ filter_module_names : List[str], optional
156
+ Modules to look for manifests, by default all available modules
157
+ """
158
+ LOGGER.debug("Checking python requirements of Modules: %s", ", ".join(filter_module_names))
159
+ available_modules = get_odoo_module_paths(addon_paths)
160
+ available_module_names = [p.stem for p in available_modules]
161
+ if not filter_module_names:
162
+ filter_module_names = available_module_names
163
+ filter_module_names = [f for f in filter_module_names if f not in ["base", "web"]]
164
+
165
+ if unavailable_modules := [m for m in filter_module_names if m not in available_module_names]:
166
+ LOGGER.warning("Couldn't search Python reqs for unavailable Modules: %s", ", ".join(unavailable_modules))
167
+
168
+ check_modules = [mp for mp in available_modules if mp.stem in filter_module_names]
169
+ if not check_modules:
170
+ LOGGER.debug("No Modules provided to check for python Requirements")
171
+ return
172
+ python_depends = []
173
+ for module_path in check_modules:
174
+ manifest_path = module_path / "__manifest__.py"
175
+ LOGGER.debug("Loading Manifest: %s", manifest_path.absolute())
176
+ manifest = literal_eval(manifest_path.read_text())
177
+ if module_depends := manifest.get("external_dependencies", {}).get("python"):
178
+ python_depends += module_depends
179
+
180
+ return python_depends
File without changes
File without changes