Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Getting "openerp.tools.safe_eval: Cannot eval '# -*- encoding: utf-8 " error. Please can any one help me?

By
samba
on 2/5/15, 7:52 AM 1,672 views

 I want to migrate my code and databases to ubuntu 12.04 Lts to cent os  cloud server. I have installed all dependencies and copied my code to cent os server using scp command and restored my database. When i run  odoo server without including custom modules folder(./openerp-server --addons ./addons) my database working fine. When i include custom modules (./openerp-server --addons ./addons,./custom_modules). I am getting below error.

2015-02-05 12:39:14,811 16954 INFO pinatascom openerp.modules.loading: loading 1 modules...
2015-02-05 12:39:14,826 16954 ERROR pinatascom openerp.tools.safe_eval: Cannot eval '# -*- encoding: utf-8 -*-\r\n#################################################################################\r\n#                                                                               \r\n#    base_onchange_player for OpenERP                                           \r\n#    Copyright (C) 2011 Akretion S\xc3\xa9bastien BEAU <sebastien.beau@akretion.com>   \r\n#                                                                               \r\n#    This program is free software: you can redistribute it and/or modify       \r\n#    it under the terms of the GNU Affero General Public License as             \r\n#    published by the Free Software Foundation, either version 3 of the         \r\n#    License, or (at your option) any later version.                            \r\n#                                                                               \r\n#    This program is distributed in the hope that it will be useful,            \r\n#    but WITHOUT ANY WARRANTY; without even the implied warranty of             \r\n#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              \r\n#    GNU Affero General Public License for more details.                        \r\n#                                                                               \r\n#    You should have received a copy of the GNU Affero General Public License   \r\n#    along with this program.  If not, see <http://www.gnu.org/licenses/>.      \r\n#                                                                               \r\n#################################################################################\r\n\r\n\r\n{\r\n    \'name\': \'base_onchange_player\',\r\n    \'version\': \'0.1\',\r\n    \'category\': \'ORM Extention\',\r\n    \'license\': \'AGPL-3\',\r\n    \'description\': """This module give the possibility to call onchange method easily in your code, it\'s just an Abstract Module that add some abstraction when you need to call onchange method.\r\n        A sample of call is done in the module base_sale_multichannels\r\n        """,\r\n    \'author\': \'Akretion\',\r\n    \'website\': \'http://www.akretion.com/\',\r\n    \'depends\': [\'base\'], \r\n    \'init_xml\': [],\r\n    \'update_xml\': [\r\n    ],\r\n    \'demo_xml\': [],\r\n    \'installable\': True,\r\n    \'active\': False,\r\n}\r\n\r\n'
Traceback (most recent call last):
  File "/home/praveen/odoo-7-2015-01-12/openerp/tools/safe_eval.py", line 287, in safe_eval
    return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
  File "/home/praveen/odoo-7-2015-01-12/openerp/tools/safe_eval.py", line 161, in test_expr
    code_obj = compile(expr, "", mode)
  File "<string>", line 21
     
    ^
 SyntaxError: invalid syntax
2015-02-05 12:39:14,826 16954 ERROR pinatascom openerp.netsvc: invalid syntax
('', 21, 1, '\r\n')
Traceback (most recent call last):
  File "/home/praveen/odoo-7-2015-01-12/openerp/netsvc.py", line 296, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/home/praveen/odoo-7-2015-01-12/openerp/service/web_services.py", line 622, in dispatch
    security.check(db,uid,passwd)
  File "/home/praveen/odoo-7-2015-01-12/openerp/service/security.py", line 40, in check
    pool = pooler.get_pool(db)
  File "/home/praveen/odoo-7-2015-01-12/openerp/pooler.py", line 49, in get_pool
    return get_db_and_pool(db_name, force_demo, status, update_module)[1]
  File "/home/praveen/odoo-7-2015-01-12/openerp/pooler.py", line 33, in get_db_and_pool
    registry = RegistryManager.get(db_name, force_demo, status, update_module)
  File "/home/praveen/odoo-7-2015-01-12/openerp/modules/registry.py", line 203, in get
    update_module)
  File "/home/praveen/odoo-7-2015-01-12/openerp/modules/registry.py", line 233, in new
    openerp.modules.load_modules(registry.db, force_demo, status, update_module)
  File "/home/praveen/odoo-7-2015-01-12/openerp/modules/loading.py", line 351, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/home/praveen/odoo-7-2015-01-12/openerp/modules/loading.py", line 254, in load_marked_modules
    graph.add_modules(cr, module_list, force)
  File "/home/praveen/odoo-7-2015-01-12/openerp/modules/graph.py", line 102, in add_modules
    info = openerp.modules.module.load_information_from_description_file(module)
  File "/home/praveen/odoo-7-2015-01-12/openerp/modules/module.py", line 344, in load_information_from_description_file
    info.update(eval(f.read()))
  File "/home/praveen/odoo-7-2015-01-12/openerp/tools/safe_eval.py", line 287, in safe_eval
    return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
  File "/home/praveen/odoo-7-2015-01-12/openerp/tools/safe_eval.py", line 161, in test_expr
    code_obj = compile(expr, "", mode)
  File "<string>", line 21
     
    ^
 SyntaxError: invalid syntax
2015-02-05 12:39:14,831 16954 INFO pinatascom werkzeug: 183.82.101.76 - - [05/Feb/2015 12:39:14] "POST /web/action/load HTTP/1.1" 200 -
2015-02-05 12:39:15,247 16954 INFO ? werkzeug: 183.82.101.76 - - [05/Feb/2015 12:39:15] "GET /web/static/lib/jquery.ui.bootstrap/css/custom-theme/images/ui-icons_222222_256x240.png HTTP/1.1" 304 -
^[[1;2B

Can any one please help me?

2

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 2/5/15, 9:03 AM

It looks like the file has been altered to use Win32 style line breaks while you're running OpenERP in Linux.  Try to convert it to Unix style line breaks first.  Follow the instruction here.

Thank you Ivan. But i am running my server in Centos not in windows

samba
on 2/9/15, 7:17 AM

Great! working fine

samba
on 2/9/15, 8:27 AM

A bit late, but that is exactly the problem @samba. It seems that you are using Win32 encoded file in Linux environment.

Ivan
on 2/10/15, 2:10 AM
1

zbik

--zbik--
5941
| 6 4 7
Lodz, Poland
--zbik--


zbik
On 2/9/15, 7:05 AM

In your file I see '\r\n', @Ivan answer is right. '\n' writes a newline in UNIX while for Windows there is the two character sequence: '\r\n'

Thank you Zbik. But i am running my server in Centos not in windows. Previously my code in ubuntu. I have transfered my code using scp command to centos server.

samba
on 2/9/15, 7:19 AM

Centos = Unix, why do you have in your file '\r\n\???

zbik
on 2/9/15, 7:24 AM

How can i change it?

samba
on 2/9/15, 7:35 AM

Link in @Ivan post.

zbik
on 2/9/15, 7:50 AM

Thank you Zbik

samba
on 2/9/15, 8:27 AM
1

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

deep
On 2/5/15, 10:14 AM

Looks like __openerp__.py("base_onchange_player")  file is corrupted ... may be some junk character/data has got added to that file, do have a look it...

I had also faced the same error, so do check it out

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/5/15, 7:52 AM
Seen: 1672 times
Last updated: 3/16/15, 8:10 AM