initOS / odoo-analyse

Package to analyse and visualize odoo modules from the setup.py
GNU Lesser General Public License v3.0
25 stars 5 forks source link

ValueError: malformed node or string #7

Closed m3asmi closed 1 year ago

m3asmi commented 3 years ago
$ odoo_analyse --path ./ --show-dependency
malformed node or string: <_ast.BinOp object at 0x7f1925875460>
Traceback (most recent call last):
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/module.py", line 430, in find_modules_iter
    module = cls.from_path(path)
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/module.py", line 383, in from_path
    module._parse_python(path, f)
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/module.py", line 239, in _parse_python
    self._parse_python("%s%s/" % (p, f), "__init__.py")
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/module.py", line 237, in _parse_python
    self._parse_python(p, f + ".py")
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/module.py", line 221, in _parse_python
    self._parse_class_def(child, content)
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/module.py", line 194, in _parse_class_def
    model = Model.from_ast(obj, content)
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/model.py", line 107, in from_ast
    model._parse_assign(child, content)
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/model.py", line 64, in _parse_assign
    value = ast.literal_eval(value)
  File "/usr/lib/python3.8/ast.py", line 99, in literal_eval
    return _convert(node_or_string)
  File "/usr/lib/python3.8/ast.py", line 98, in _convert
    return _convert_signed_num(node)
  File "/usr/lib/python3.8/ast.py", line 75, in _convert_signed_num
    return _convert_num(node)
  File "/usr/lib/python3.8/ast.py", line 66, in _convert_num
    _raise_malformed_node(node)
  File "/usr/lib/python3.8/ast.py", line 63, in _raise_malformed_node
    raise ValueError(f'malformed node or string: {node!r}')
ValueError: malformed node or string: <_ast.BinOp object at 0x7f1925875460>
fkantelberg commented 3 years ago

@m3asmi Thank you for the report.

Can you provide a bit more information which can help with the analyze?

  1. Version of odoo_analyse
  2. Which Odoo version would the modules be?
  3. Are you analyzing a single module or multiple ones?

At first glance it looks like a problem with one of the _inherit in your modules. If you can find out the specific module and post the specific code snippet with the _inherit it would be a great help.

m3asmi commented 3 years ago

Hello, thanks for your response, I used $ pip3 install "odoo-analyse[graph]" to install it now how can I find the module that contains the problem ?

fkantelberg commented 3 years ago

How do you start the tool?

Currently you can only try to run odoo_analyse -p <path> to analyse one module at a time. You can also try to use grep -r -C 2 _inherit <path>. On your module directory. You should look for a line where the value right of the = isn't a literal (string or list.)

fkantelberg commented 3 years ago

@m3asmi I added a --verbose flag in version 1.1.2 which shows a bit more information while analysing and should print the last analysed module. I hope it helps to figure out the specific line if you update odoo_analyse.

m3asmi commented 3 years ago

Hello, I updated the code using PIP and --verbose does not exist,

rachid@EliteBook:/opt/odoo/custom/$ odoo_analyse  --path ./ --show-dependency 
malformed node or string: <_ast.BinOp object at 0x7f95deee2040>
Traceback (most recent call last):
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/module.py", line 430, in find_modules_iter
    module = cls.from_path(path)
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/module.py", line 383, in from_path
    module._parse_python(path, f)
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/module.py", line 239, in _parse_python
    self._parse_python("%s%s/" % (p, f), "__init__.py")
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/module.py", line 237, in _parse_python
    self._parse_python(p, f + ".py")
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/module.py", line 221, in _parse_python
    self._parse_class_def(child, content)
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/module.py", line 194, in _parse_class_def
    model = Model.from_ast(obj, content)
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/model.py", line 107, in from_ast
    model._parse_assign(child, content)
  File "/home/rachid/.local/lib/python3.8/site-packages/odoo_analyse/model.py", line 64, in _parse_assign
    value = ast.literal_eval(value)
  File "/usr/lib/python3.8/ast.py", line 99, in literal_eval
    return _convert(node_or_string)
  File "/usr/lib/python3.8/ast.py", line 98, in _convert
    return _convert_signed_num(node)
  File "/usr/lib/python3.8/ast.py", line 75, in _convert_signed_num
    return _convert_num(node)
  File "/usr/lib/python3.8/ast.py", line 66, in _convert_num
    _raise_malformed_node(node)
  File "/usr/lib/python3.8/ast.py", line 63, in _raise_malformed_node
    raise ValueError(f'malformed node or string: {node!r}')
ValueError: malformed node or string: <_ast.BinOp object at 0x7f95deee2040>
rachid@EliteBook:/opt/odoo/custom/$ odoo_analyse  --path ./ --show-dependency  --version
usage: odoo_analyse [-h] [-c CONFIG] [-p PATH] [-l LOAD] [-s SAVE] [--path-filter PATH_FILTER] [--models MODELS] [--modules MODULES] [--views VIEWS] [--test-filter] [--state-filter] [--db_host DB_HOST]
                    [--db_port DB_PORT] [--db_user DB_USER] [--db_password] [--db_name DB_NAME] [--show-dependency] [--show-import] [--show-reference] [--migration MIGRATION] [--model-graph]
                    [--no-model-inherit] [--no-model-inherits] [--view-graph] [--no-view-inherit] [--no-view-call] [--structure-graph] [--analyse ANALYSE] [--analyse-output {csv,json}] [-i] [--full-graph]
                    [--renderer RENDERER]
odoo_analyse: error: unrecognized arguments: --verbrose
fkantelberg commented 3 years ago

It doesn't look like that you are using the right version. You can check it with pip3 list. You could try pip3 install -U "odoo-analyse[graph]" or uninstall and install afterwards.