gOdoo-cli 0.9.5__tar.gz → 0.10.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.
Files changed (49) hide show
  1. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/PKG-INFO +3 -3
  2. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/pyproject.toml +3 -3
  3. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/bootstrap.py +0 -6
  4. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/db/query.py +17 -5
  5. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/test/cli.py +2 -1
  6. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/test/test_run.py +21 -16
  7. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/helpers/cli.py +1 -1
  8. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/helpers/odoo_files.py +30 -8
  9. godoo_cli-0.10.1/src/godoo_cli/version.py +1 -0
  10. godoo_cli-0.9.5/src/godoo_cli/version.py +0 -1
  11. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/LICENSE +0 -0
  12. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/README.md +0 -0
  13. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/__init__.py +0 -0
  14. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/__main__.py +0 -0
  15. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/cli.py +0 -0
  16. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/cli_common.py +0 -0
  17. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/__init__.py +0 -0
  18. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/backup/__init__.py +0 -0
  19. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/backup/cli.py +0 -0
  20. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/backup/dump.py +0 -0
  21. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/backup/load.py +0 -0
  22. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/backup/pull.py +0 -0
  23. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/backup/util.py +0 -0
  24. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/config.py +0 -0
  25. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/db/__init__.py +0 -0
  26. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/db/cli.py +0 -0
  27. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/db/connection.py +0 -0
  28. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/db/passwords.py +0 -0
  29. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/launch.py +0 -0
  30. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/rpc/__init__.py +0 -0
  31. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/rpc/cli.py +0 -0
  32. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/rpc/config_parameters.py +0 -0
  33. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/rpc/importer.py +0 -0
  34. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/rpc/modules.py +0 -0
  35. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/rpc/translations.py +0 -0
  36. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/shell.py +0 -0
  37. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/source_get.py +0 -0
  38. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/test/__init__.py +0 -0
  39. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/commands/test/test_load_data.py +0 -0
  40. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/git/__init__.py +0 -0
  41. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/git/git_odoo.py +0 -0
  42. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/git/git_odoo_addons.py +0 -0
  43. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/git/git_repo.py +0 -0
  44. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/git/git_url.py +0 -0
  45. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/git/zip_download.py +0 -0
  46. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/helpers/__init__.py +0 -0
  47. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/helpers/bootstrap.py +0 -0
  48. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/helpers/odoo_manifest.py +0 -0
  49. {godoo_cli-0.9.5 → godoo_cli-0.10.1}/src/godoo_cli/helpers/system.py +0 -0
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gOdoo-cli
3
- Version: 0.9.5
3
+ Version: 0.10.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
7
7
  Keywords: odoo,godoo,devcontainer
8
8
  Author: Joshua Kreuder
9
9
  Author-email: Joshua_Kreuder@outlook.com
10
- Requires-Python: >=3.8.1,<3.12
10
+ Requires-Python: >=3.9,<3.12
11
11
  Classifier: License :: Other/Proprietary License
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.9
@@ -19,7 +19,7 @@ Requires-Dist: black (>=22.10.0,<23.0.0) ; extra == "codequality"
19
19
  Requires-Dist: debugpy (>=1.6.0,<2.0.0) ; extra == "devcontainer"
20
20
  Requires-Dist: flake8 (>=5.0.4,<6.0.0) ; extra == "codequality"
21
21
  Requires-Dist: gitpython (>=3.1.27,<4.0.0)
22
- Requires-Dist: godoo-rpc (>=0.1.1,<0.2.0)
22
+ Requires-Dist: godoo-rpc (>=0.1.2,<0.2.0)
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"
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "gOdoo-cli"
3
- version = "0.9.5"
3
+ version = "0.10.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"
@@ -18,11 +18,11 @@ pre-commit = "^3.4.0"
18
18
  godoo = "godoo_cli:launch_cli"
19
19
 
20
20
  [tool.poetry.dependencies]
21
- python = ">=3.8.1,<3.12"
21
+ python = ">=3.9,<3.12"
22
22
  python-dotenv = "^0.20.0"
23
23
  ruamel-yaml = "^0.17.21"
24
24
  gitpython = "^3.1.27"
25
- godoo-rpc = "^0.1.1"
25
+ godoo-rpc = "^0.1.2"
26
26
  openupgradelib = "^3.3.4"
27
27
  psycopg2 = "^2.8.6" # Mirror Odoo Reqs
28
28
  passlib = "^1.7.3" # Mirror Odoo Reqs
@@ -87,12 +87,6 @@ def _boostrap_command(
87
87
  if install_workspace_modules:
88
88
  if workspace_addons := get_odoo_module_paths(workspace_addon_path):
89
89
  init_modules += [f.name for f in workspace_addons]
90
- elif re.search(r"(-u|--update) ", extra_cmd_args_str):
91
- # if -u is present, do not install any modules
92
- pass
93
- else:
94
- # if no -i or -u is present, install base and web modules
95
- init_modules = ["base", "web"]
96
90
  init_cmd = "--init " + ",".join(init_modules) if init_modules else ""
97
91
 
98
92
  addon_paths = [str(p.absolute()) for p in addon_paths]
@@ -21,14 +21,21 @@ CLI = CommonCLI()
21
21
 
22
22
  @CLI.arg_annotator
23
23
  def query_database(
24
- query: str = typer.Argument(..., help="SQL Query"),
24
+ query: str = typer.Argument(..., help="SQL Query. Use '-' to read from stdin."),
25
25
  db_host=CLI.database.db_host,
26
26
  db_port=CLI.database.db_port,
27
27
  db_name=CLI.database.db_name,
28
28
  db_user=CLI.database.db_user,
29
29
  db_password=CLI.database.db_password,
30
30
  ):
31
- """Run a Query against the database."""
31
+ """Run a Query against the database.
32
+ Queries, with return values will be printed to stdout between "START QUERY_OUTPUT" and "END QUERY_OUTPUT".
33
+ """
34
+
35
+ # read stdin if query is not provided
36
+ if query == "-":
37
+ stdin = typer.get_text_stream("stdin")
38
+ query = stdin.read()
32
39
 
33
40
  check_dangerous_command()
34
41
  # regex to check if SQL query contains writing command
@@ -42,14 +49,20 @@ def query_database(
42
49
  )
43
50
  with connection.connect() as cursor:
44
51
  try:
45
- LOGGER.info("Running Query: %s", query)
52
+ LOGGER.info("Running Query against Odoo DB: %s", query)
46
53
  cursor.execute(query)
47
54
  LOGGER.info("Affected Rows: %s", cursor.rowcount)
48
55
  try:
49
56
  rows = cursor.fetchall()
57
+ # Use Print here to write to Stdout.
58
+ # START and END query are there to help parsing the actual output
59
+ print("START QUERY_OUTPUT") # pylint: disable=print-used
50
60
  for row in rows:
51
- print("\t".join(row)) # pylint: disable=print-used
61
+ print_line = "\t".join(map(str, row)) if isinstance(row, tuple) else str(row)
62
+ print(print_line) # pylint: disable=print-used
63
+ print("END QUERY_OUTPUT") # pylint: disable=print-used
52
64
  except ProgrammingError:
65
+ # When there is nothing to fetch, fetchall() raises a ProgrammingError
53
66
  pass
54
67
  except Exception as e:
55
68
  LOGGER.exception(e)
@@ -80,7 +93,6 @@ def is_bootstrapped(
80
93
  db_password=CLI.database.db_password,
81
94
  ):
82
95
  """Check if the database is empty. Return code = 1 if database does not exist, 2 if database is empty, 0 if database is not empty."""
83
- check_dangerous_command()
84
96
  connection = DBConnection(
85
97
  hostname=db_host,
86
98
  port=db_port,
@@ -1,7 +1,7 @@
1
1
  import typer
2
2
 
3
3
  from .test_load_data import odoo_load_test_data
4
- from .test_run import odoo_run_tests
4
+ from .test_run import odoo_get_changed_modules, odoo_run_tests
5
5
 
6
6
 
7
7
  def test_cli_app():
@@ -11,5 +11,6 @@ def test_cli_app():
11
11
  )
12
12
  app.command(name="run")(odoo_run_tests)
13
13
  app.command(name="load-data")(odoo_load_test_data)
14
+ app.command(name="get-changed-modules")(odoo_get_changed_modules)
14
15
 
15
16
  return app
@@ -7,7 +7,7 @@ import typer
7
7
  from typing_extensions import Annotated
8
8
 
9
9
  from ...cli_common import CommonCLI
10
- from ...helpers.odoo_files import get_changed_modules, get_depends_of_module, get_odoo_module_paths
10
+ from ...helpers.odoo_files import get_changed_modules_and_depends, get_odoo_module_paths
11
11
  from ...helpers.system import run_cmd
12
12
  from ..db.connection import DBConnection
13
13
  from ..launch import pre_launch
@@ -19,28 +19,33 @@ LOGGER = logging.getLogger(__name__)
19
19
 
20
20
  def _test_modules_special_cases(in_modules: List[str], workspace_addon_path: Path):
21
21
  if len(in_modules) == 1:
22
- command = in_modules[0]
23
22
  out_modules = []
23
+ command = in_modules[0]
24
24
  if command == "all":
25
25
  out_modules = get_odoo_module_paths(workspace_addon_path)
26
-
27
- if re_match := re.match(r"changes\:(.*)", command):
26
+ elif re_match := re.match(r"changes\:(.*)", command):
28
27
  compare_branch = re_match.group(1)
29
- changed_modules = get_changed_modules(addon_path=workspace_addon_path, diff_branch=compare_branch)
30
- if not changed_modules:
31
- return []
32
- change_modules_depends = []
33
- for module in changed_modules:
34
- change_modules_depends += get_depends_of_module(
35
- out_modules, module, already_done_modules=change_modules_depends
36
- )
37
- out_modules = changed_modules + change_modules_depends
38
- if out_modules:
39
- out_modules_with_tests = [p for p in out_modules if any(p.rglob("tests/__init__.py"))]
40
- return [p.stem for p in out_modules_with_tests]
28
+ changed_modules = get_changed_modules_and_depends(
29
+ diff_ref=compare_branch,
30
+ addon_path=workspace_addon_path,
31
+ )
32
+ out_modules = changed_modules
33
+ return [p.stem for p in out_modules]
41
34
  return in_modules
42
35
 
43
36
 
37
+ @CLI.arg_annotator
38
+ def odoo_get_changed_modules(
39
+ diff_ref: str = typer.Argument(..., help="Git Ref/Branch to compare against"),
40
+ workspace_addon_path=CLI.odoo_paths.workspace_addon_path,
41
+ ):
42
+ """Get Modules that have changed compared to diff_ref"""
43
+ changed_modules = get_changed_modules_and_depends(diff_ref=diff_ref, addon_path=workspace_addon_path)
44
+ if not changed_modules:
45
+ return
46
+ print("\n".join(sorted([p.stem for p in changed_modules]))) # pylint: disable=print-used
47
+
48
+
44
49
  @CLI.arg_annotator
45
50
  def odoo_run_tests(
46
51
  test_modules: List[str] = typer.Argument(
@@ -12,4 +12,4 @@ def check_dangerous_command():
12
12
  Please set 'WORKSPACE_IS_DEV=true' as environment Variable to continue
13
13
  """
14
14
  )
15
- exit(1)
15
+ exit(420)
@@ -98,8 +98,9 @@ def get_odoo_module_paths(
98
98
  raise FileNotFoundError(f"Could not find odoo addon folder: '{folder}'")
99
99
  for folder in folder.iterdir():
100
100
  if folder_is_odoo_module(folder):
101
- module_paths.append(folder)
101
+ module_paths.append(folder.absolute())
102
102
  if module_names:
103
+ module_names = [m for m in module_names if m != "base"]
103
104
  filtered_module_paths = [p for p in module_paths if p.stem in module_names]
104
105
  if unavailable_modules := set(module_names).difference([p.stem for p in filtered_module_paths]):
105
106
  LOGGER.warning("Could not find Module folder for: %s", unavailable_modules)
@@ -109,7 +110,7 @@ def get_odoo_module_paths(
109
110
 
110
111
  def get_changed_modules(
111
112
  addon_path: Path,
112
- diff_branch: str,
113
+ diff_ref: str,
113
114
  ) -> List[Path]:
114
115
  """Get Paths of changed modules since git diff.
115
116
 
@@ -117,7 +118,7 @@ def get_changed_modules(
117
118
  ----------
118
119
  addon_path : Path
119
120
  Folder in git repo where to look for changes
120
- diff_branch : str
121
+ diff_ref : str
121
122
  Branch or diffable ref for git
122
123
 
123
124
  Returns
@@ -126,10 +127,11 @@ def get_changed_modules(
126
127
  List of Paths where something has changed since git diff
127
128
  """
128
129
  addon_path = addon_path.absolute()
130
+ odoo_module_paths = get_odoo_module_paths(addon_path)
129
131
  repo = Repo(addon_path, search_parent_directories=True)
130
132
  git_root = Path(repo.git.rev_parse("--show-toplevel"))
131
133
  changed_module_files = []
132
- for change in repo.git.diff("--name-status", diff_branch).split("\n"):
134
+ for change in repo.git.diff("--name-status", diff_ref).split("\n"):
133
135
  path = git_root / change.split("\t")[1]
134
136
  if addon_path in path.parents:
135
137
  changed_module_files.append(path)
@@ -137,14 +139,15 @@ def get_changed_modules(
137
139
  changed_module_folders = []
138
140
  for f in changed_module_files:
139
141
  for pf in f.parents:
140
- if pf.absolute() == addon_path.absolute():
141
- break
142
- if pf.absolute() not in changed_module_folders and folder_is_odoo_module(pf):
142
+ if pf.absolute() in odoo_module_paths:
143
143
  changed_module_folders.append(pf.absolute())
144
+ break
145
+ if pf.absolute() == addon_path:
146
+ break
144
147
  if changed_module_folders:
145
148
  LOGGER.debug(
146
149
  "Found Modules changed to branch '%s':\n %s",
147
- diff_branch,
150
+ diff_ref,
148
151
  changed_module_folders,
149
152
  )
150
153
  return changed_module_folders
@@ -197,6 +200,25 @@ def get_depends_of_module(
197
200
  return list(set(sub_depends))
198
201
 
199
202
 
203
+ def get_changed_modules_and_depends(diff_ref: str, addon_path: Path):
204
+ """Get Modules that have changed compared to diff_ref and all their dependencies downstream"""
205
+ all_modules = get_odoo_module_paths(addon_path)
206
+ changed_modules = get_changed_modules(addon_path=addon_path, diff_ref=diff_ref)
207
+ if not changed_modules:
208
+ return []
209
+ change_modules_depends = []
210
+ changed_module_names = [p.stem for p in changed_modules]
211
+ for module in all_modules:
212
+ # Check if there are other modules in addon path, that depend on a changed module
213
+ module_manifest = module / "__manifest__.py"
214
+ manifest = literal_eval(module_manifest.read_text())
215
+ depends = manifest.get("depends", [])
216
+ for depend in depends:
217
+ if depend in changed_module_names:
218
+ change_modules_depends.append(module)
219
+ return list(set(changed_modules + change_modules_depends))
220
+
221
+
200
222
  def get_addon_paths(
201
223
  odoo_main_repo: Path,
202
224
  workspace_addon_path: Path,
@@ -0,0 +1 @@
1
+ __version__ = "0.10.1"
@@ -1 +0,0 @@
1
- __version__ = "0.9.5"
File without changes
File without changes