gOdoo-cli 0.1.1__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 (32) hide show
  1. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/PKG-INFO +6 -1
  2. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/README.md +2 -0
  3. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/pyproject.toml +6 -1
  4. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/setup.py +3 -3
  5. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/__init__.py +1 -1
  6. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/commands/bootstrap.py +66 -20
  7. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/commands/launch.py +10 -45
  8. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/commands/rpc/translations.py +2 -2
  9. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/commands/shell.py +3 -3
  10. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/commands/source_get.py +10 -12
  11. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/commands/test.py +2 -2
  12. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/helpers/__init__.py +19 -0
  13. godoo_cli-0.1.4/src/godoo_cli/helpers/odoo_files.py +180 -0
  14. godoo_cli-0.1.1/src/godoo_cli/helpers/odoo_files.py +0 -105
  15. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/LICENSE +0 -0
  16. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/__main__.py +0 -0
  17. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/cli.py +0 -0
  18. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/commands/__init__.py +0 -0
  19. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/commands/makedev.py +0 -0
  20. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/commands/rpc/__init__.py +0 -0
  21. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/commands/rpc/cli.py +0 -0
  22. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/commands/rpc/cli_callbacks.py +0 -0
  23. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/commands/rpc/importer.py +0 -0
  24. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/commands/rpc/modules.py +0 -0
  25. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/git/__init__.py +0 -0
  26. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/git/git_odoo.py +0 -0
  27. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/git/git_odoo_addons.py +0 -0
  28. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/git/git_repo.py +0 -0
  29. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/git/git_url.py +0 -0
  30. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/git/zip_download.py +0 -0
  31. {godoo_cli-0.1.1 → godoo_cli-0.1.4}/src/godoo_cli/helpers/cli.py +0 -0
  32. {godoo_cli-0.1.1 → 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.1
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
@@ -37,6 +40,8 @@ Description-Content-Type: text/markdown
37
40
  ![OdooLogo](https://raw.githubusercontent.com/OpenJKSoftware/gOdoo/main/assets/odoo_logo.png)
38
41
  ![ComposeLogo](https://raw.githubusercontent.com/docker/compose/v2/logo.png)
39
42
 
43
+ [<img src="https://raw.githubusercontent.com/OpenJKSoftware/gOdoo/main/assets/godoo-main-cli.png" width="1000"/>](image.png)
44
+
40
45
  **gOdoo** is short for **go Odoo**. \
41
46
  It is a [Vscode Devcontainer](https://code.visualstudio.com/docs/remote/containers) Environment for [Odoo](https://odoo.com/)
42
47
  with Python CLI `godoo` convenience wrapper around `odoo-bin`.
@@ -3,6 +3,8 @@
3
3
  ![OdooLogo](https://raw.githubusercontent.com/OpenJKSoftware/gOdoo/main/assets/odoo_logo.png)
4
4
  ![ComposeLogo](https://raw.githubusercontent.com/docker/compose/v2/logo.png)
5
5
 
6
+ [<img src="https://raw.githubusercontent.com/OpenJKSoftware/gOdoo/main/assets/godoo-main-cli.png" width="1000"/>](image.png)
7
+
6
8
  **gOdoo** is short for **go Odoo**. \
7
9
  It is a [Vscode Devcontainer](https://code.visualstudio.com/docs/remote/containers) Environment for [Odoo](https://odoo.com/)
8
10
  with Python CLI `godoo` convenience wrapper around `odoo-bin`.
@@ -1,11 +1,13 @@
1
1
  [tool.poetry]
2
2
  name = "gOdoo-cli"
3
- version = "0.1.1"
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.1',
43
+ 'version': '0.1.4',
44
44
  'description': 'Wrapper around Odoo-Bin with some convinience RPC functions.',
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**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',
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.1"
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_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,17 +137,9 @@ 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 = [str((odoo_main_path / "addons").absolute())]
98
- if workspace_addons:
99
- addon_paths.append(str(workspace_addon_path.absolute()))
100
-
101
- thirdparty_addon_paths = [
102
- str(p) for p in thirdparty_addon_path.glob("*") if p.is_dir() and get_odoo_addons_in_folder(p)
103
- ]
104
- if thirdparty_addon_paths:
105
- addon_paths += thirdparty_addon_paths
106
-
140
+ addon_paths = [str(p.absolute()) for p in addon_paths]
107
141
  addon_paths = ", ".join(list(filter(None, addon_paths)))
142
+
108
143
  base_cmds = [
109
144
  str(odoo_main_path.absolute()) + "/odoo-bin",
110
145
  init_cmd,
@@ -157,11 +192,18 @@ def bootstrap_odoo(
157
192
  if update_source:
158
193
  get_source(ctx=ctx, remove_unspecified_addons=addons_remove_unspecified)
159
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
+
160
202
  cmd_string = _boostrap_command(
161
203
  odoo_main_path=ctx.obj.odoo_main_path,
162
204
  odoo_conf_path=ctx.obj.odoo_conf_path,
163
- thirdparty_addon_path=thirdparty_addon_path,
164
205
  workspace_addon_path=ctx.obj.workspace_addon_path,
206
+ addon_paths=addon_paths,
165
207
  db_host=db_host,
166
208
  db_name=db_name,
167
209
  db_filter=db_filter,
@@ -174,8 +216,12 @@ def bootstrap_odoo(
174
216
  multithread_worker_count=multithread_worker_count,
175
217
  languages=languages,
176
218
  )
177
- LOGGER.info('Launching Bootstrap Commandline: "%s"', cmd_string)
178
- 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
179
225
  if ret == 0:
180
226
  ctx.obj.bootstrap_flag_location.touch()
181
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)
@@ -12,7 +12,7 @@ from ruamel.yaml import YAML
12
12
  from ..git import GitUrl, git_ensure_addon_repos, git_ensure_odoo_repo
13
13
  from ..helpers import download_file
14
14
  from ..helpers.cli import typer_unpacker
15
- from ..helpers.odoo_files import get_odoo_addons_in_folder
15
+ from ..helpers.odoo_files import get_addon_paths
16
16
  from ..helpers.odoo_manifest import remove_unused_folders
17
17
 
18
18
  LOGGER = logging.getLogger(__name__)
@@ -70,7 +70,7 @@ def update_odoo_conf_addon_paths(odoo_conf: Path, addon_paths: List[Path]):
70
70
  @typer_unpacker
71
71
  def get_source_file(
72
72
  manifest_yml: Path = typer.Option(
73
- "", envvar="ODOO_GITSPEC", help="godoo manifest path, when downloading odoo source (skip repo_url)"
73
+ "", envvar="ODOO_MANIFEST", help="godoo manifest path, when downloading odoo source (skip repo_url)"
74
74
  ),
75
75
  repo_url: str = typer.Option("", help="git repo url, for specific repo (skip manifest_yml)"),
76
76
  file_ref: str = typer.Option("", help="When not using manifest. File Branch, Commit, Tag..."),
@@ -102,7 +102,7 @@ def get_source_file(
102
102
  def get_source(
103
103
  ctx: typer.Context,
104
104
  manifest_yml: Path = typer.Option(
105
- ..., envvar="ODOO_GITSPEC", help="Git.yml file, that specified what to download with wich prefix"
105
+ ..., envvar="ODOO_MANIFEST", help="Git.yml file, that specified what to download with wich prefix"
106
106
  ),
107
107
  thirdparty_addon_path: Path = typer.Option(
108
108
  ..., envvar="ODOO_THIRDPARTY_LOCATION", help="Root folder of the Thirdparty addon repos"
@@ -124,7 +124,7 @@ def get_source(
124
124
  ):
125
125
  """Update Odoo Source and Thirdparty source."""
126
126
  LOGGER.info("Updating Source Repos")
127
- zip_addon_path = thirdparty_addon_path / "custom"
127
+ zip_addon_path = thirdparty_addon_path / "custom" # !Todo Pull out into variable (same in bootstrap)
128
128
 
129
129
  if update_mode in ["all", "zip"]:
130
130
  unzip_addons(thirdparty_zip_source, zip_addon_path)
@@ -153,12 +153,10 @@ def get_source(
153
153
  )
154
154
 
155
155
  if (conf_path := ctx.obj.odoo_conf_path).exists():
156
- odoo_addon_paths = [ctx.obj.odoo_main_path / "addons"]
157
- if get_odoo_addons_in_folder(ctx.obj.workspace_addon_path):
158
- odoo_addon_paths.append(ctx.obj.workspace_addon_path)
159
- if get_odoo_addons_in_folder(zip_addon_path):
160
- odoo_addon_paths.append(zip_addon_path)
161
- odoo_addon_paths += [
162
- p for p in thirdparty_addon_path.iterdir() if p.is_dir() and not p.resolve() == zip_addon_path.resolve()
163
- ]
156
+ odoo_addon_paths = get_addon_paths(
157
+ odoo_main_repo=ctx.obj.odoo_main_path,
158
+ workspace_addon_path=ctx.obj.workspace_addon_path,
159
+ zip_addon_path=zip_addon_path,
160
+ thirdparty_addon_path=thirdparty_addon_path,
161
+ )
164
162
  update_odoo_conf_addon_paths(odoo_conf=conf_path, addon_paths=odoo_addon_paths)
@@ -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.
@@ -0,0 +1,180 @@
1
+ """Functions that operate on Odoos Source Code."""
2
+ import logging
3
+ from ast import literal_eval
4
+ from pathlib import Path
5
+ from typing import List, Union
6
+
7
+ from git import Repo
8
+
9
+ LOGGER = logging.getLogger(__name__)
10
+
11
+
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
+
15
+ Parameters
16
+ ----------
17
+ search_folders : Path
18
+ Folder(s) to search in.
19
+
20
+ Returns
21
+ -------
22
+ List[Path]
23
+ List of Valid Module Folders within search_folder
24
+ """
25
+ if not isinstance(search_folders, List):
26
+ search_folders = [search_folders]
27
+
28
+ module_paths = []
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)
35
+ return module_paths
36
+
37
+
38
+ def get_changed_modules(
39
+ addon_path: Path,
40
+ diff_branch: str,
41
+ ) -> List[Path]:
42
+ """Get Paths of changed modules since git diff.
43
+
44
+ Parameters
45
+ ----------
46
+ addon_path : Path
47
+ Folder in git repo where to look for changes
48
+ diff_branch : str
49
+ Branch or diffable ref for git
50
+
51
+ Returns
52
+ -------
53
+ List[Path]
54
+ List of Paths where something has changed since git diff
55
+ """
56
+ addon_path = addon_path.absolute()
57
+ repo = Repo(addon_path, search_parent_directories=True)
58
+ git_root = Path(repo.git.rev_parse("--show-toplevel"))
59
+ changed_module_files = []
60
+ for change in repo.git.diff("--name-status", diff_branch).split("\n"):
61
+ path = git_root / change.split("\t")[1]
62
+ if addon_path in path.parents:
63
+ changed_module_files.append(path)
64
+ changed_module_folders = list(set([f.parent.absolute() for f in changed_module_files]))
65
+ if changed_module_folders:
66
+ LOGGER.debug(
67
+ "Found Modules changed to branch '%s':\n %s",
68
+ diff_branch,
69
+ "\n".join(["\t" + str(f) for f in changed_module_folders]),
70
+ )
71
+ return changed_module_folders
72
+
73
+
74
+ def get_depends_of_modules(addon_path: Path, in_module_paths: List[Path]) -> List[Path]:
75
+ """Get Modules which do depend on given modules. Recursive.
76
+
77
+ Parameters
78
+ ----------
79
+ addon_path : Path
80
+ Folder where to look for Depends of in_module_paths
81
+ in_module_paths : List[Path]
82
+ List of Module Paths of which we want to get the downstream dependencies
83
+
84
+ Returns
85
+ -------
86
+ List[Path]
87
+ Union of in_module_paths and all their downstream depends.
88
+ """
89
+ all_modules = get_odoo_module_paths(addon_path)
90
+ if not in_module_paths:
91
+ return
92
+ added = True
93
+ LOGGER.debug("Searching Depends for: %s", ", ".join([str(p) for p in in_module_paths]))
94
+ out_depends = in_module_paths.copy()
95
+ while added:
96
+ added = False
97
+ for module in all_modules:
98
+ manifest_path = module / "__manifest__.py"
99
+ current_module = module.absolute()
100
+ if current_module in out_depends:
101
+ continue
102
+ LOGGER.debug("Loading Manifest: %s", manifest_path.absolute())
103
+ manifest = literal_eval(manifest_path.read_text())
104
+ module_depends = manifest.get("depends", [])
105
+ if any(item.stem in module_depends for item in out_depends):
106
+ out_depends.append(module.absolute())
107
+ added = True
108
+ LOGGER.debug("Found Depends: %s", ", ".join([str(d) for d in out_depends if d not in in_module_paths]))
109
+ return out_depends
110
+
111
+
112
+ def get_addon_paths(
113
+ odoo_main_repo: Path,
114
+ workspace_addon_path: Path,
115
+ zip_addon_path: Path,
116
+ thirdparty_addon_path: Path,
117
+ ) -> List[Path]:
118
+ """Get Odoo Addon Paths for odoo.conf.
119
+
120
+ Parameters
121
+ ----------
122
+ odoo_main_repo : Path
123
+ Path to main odoo repo
124
+ workspace_addon_path : Path
125
+ Path to workspace addons
126
+ zip_addon_path : Path
127
+ path to zip addons
128
+ thirdparty_addon_path : Path
129
+ path to git cloned addon repos
130
+
131
+ Returns
132
+ -------
133
+ List[Path]
134
+ List of valid addon Paths
135
+ """
136
+ odoo_addon_paths = [odoo_main_repo / "addons"]
137
+ if get_odoo_module_paths(workspace_addon_path):
138
+ odoo_addon_paths.append(workspace_addon_path)
139
+ zip_addon_repos = [f for f in zip_addon_path.iterdir() if f.is_dir() and get_odoo_module_paths(f)]
140
+ odoo_addon_paths += zip_addon_repos
141
+ git_thirdparty_addon_repos = [
142
+ p for p in thirdparty_addon_path.iterdir() if p.is_dir() and not p.resolve() == zip_addon_path.resolve()
143
+ ]
144
+ odoo_addon_paths += git_thirdparty_addon_repos
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
@@ -1,105 +0,0 @@
1
- """Functions that operate on Odoos Source Code."""
2
- import logging
3
- from ast import literal_eval
4
- from pathlib import Path
5
- from typing import List
6
-
7
- from git import Repo
8
-
9
- LOGGER = logging.getLogger(__name__)
10
-
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.
14
-
15
- Parameters
16
- ----------
17
- search_folder : Path
18
- Folder to search in.
19
-
20
- Returns
21
- -------
22
- List[Path]
23
- List of Valid Module Folders within search_folder
24
- """
25
- 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)
31
- return module_paths
32
-
33
-
34
- def get_changed_modules(
35
- addon_path: Path,
36
- diff_branch: str,
37
- ) -> List[Path]:
38
- """Get Paths of changed modules since git diff.
39
-
40
- Parameters
41
- ----------
42
- addon_path : Path
43
- Folder in git repo where to look for changes
44
- diff_branch : str
45
- Branch or diffable ref for git
46
-
47
- Returns
48
- -------
49
- List[Path]
50
- List of Paths where something has changed since git diff
51
- """
52
- addon_path = addon_path.absolute()
53
- repo = Repo(addon_path, search_parent_directories=True)
54
- git_root = Path(repo.git.rev_parse("--show-toplevel"))
55
- changed_module_files = []
56
- for change in repo.git.diff("--name-status", diff_branch).split("\n"):
57
- path = git_root / change.split("\t")[1]
58
- if addon_path in path.parents:
59
- changed_module_files.append(path)
60
- changed_module_folders = list(set([f.parent.absolute() for f in changed_module_files]))
61
- if changed_module_folders:
62
- LOGGER.debug(
63
- "Found Modules changed to branch '%s':\n %s",
64
- diff_branch,
65
- "\n".join(["\t" + str(f) for f in changed_module_folders]),
66
- )
67
- return changed_module_folders
68
-
69
-
70
- def get_depends_of_modules(addon_path: Path, in_module_paths: List[Path]) -> List[Path]:
71
- """Get Modules which do depend on given modules. Recursive.
72
-
73
- Parameters
74
- ----------
75
- addon_path : Path
76
- Folder where to look for Depends of in_module_paths
77
- in_module_paths : List[Path]
78
- List of Module Paths of which we want to get the downstream dependencies
79
-
80
- Returns
81
- -------
82
- List[Path]
83
- Union of in_module_paths and all their downstream depends.
84
- """
85
- all_modules = get_odoo_addons_in_folder(addon_path)
86
- if not in_module_paths:
87
- return
88
- added = True
89
- LOGGER.debug("Searching Depends for: %s", ", ".join([str(p) for p in in_module_paths]))
90
- out_depends = in_module_paths.copy()
91
- while added:
92
- added = False
93
- for module in all_modules:
94
- manifest_path = module / "__manifest__.py"
95
- current_module = module.absolute()
96
- if current_module in out_depends:
97
- continue
98
- LOGGER.debug("Loading Manifest: %s", manifest_path.absolute())
99
- manifest = literal_eval(manifest_path.read_text())
100
- module_depends = manifest.get("depends", [])
101
- if any(item.stem in module_depends for item in out_depends):
102
- out_depends.append(module.absolute())
103
- added = True
104
- LOGGER.debug("Found Depends: %s", ", ".join([str(d) for d in out_depends if d not in in_module_paths]))
105
- return out_depends
File without changes