I've implemented a product called Odoo/OpenERP and recently performed a restart after changing some strings in multiple files.
These strings contained standard characters with no accented characters. After the restart, any access to the site results in the below:
2015-06-24 08:09:35,884 1584 ERROR XXXXXX-Odoo-Production werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/opt/odoo-production/openerp/service/server.py", line 290, in app
return self.app(e, s)
File "/opt/odoo-production/openerp/service/wsgi_server.py", line 216, in application
return application_unproxied(environ, start_response)
File "/opt/odoo-production/openerp/service/wsgi_server.py", line 202, in application_unproxied
result = handler(environ, start_response)
File "/opt/odoo-production/openerp/http.py", line 1290, in __call__
return self.dispatch(environ, start_response)
File "/opt/odoo-production/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo-production/openerp/http.py", line 1426, in dispatch
ir_http = request.registry['ir.http']
File "/opt/odoo-production/openerp/http.py", line 346, in registry
return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None
File "/opt/odoo-production/openerp/modules/registry.py", line 339, in get
update_module)
File "/opt/odoo-production/openerp/modules/registry.py", line 356, in new
registry = Registry(db_name)
File "/opt/odoo-production/openerp/modules/registry.py", line 60, in __init__
self._db = openerp.sql_db.db_connect(db_name)
File "/opt/odoo-production/openerp/sql_db.py", line 623, in db_connect
db, uri = dsn(to)
File "/opt/odoo-production/openerp/sql_db.py", line 614, in dsn
return db_or_uri, '%sdbname=%s' % (_dsn, db_or_uri)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 28: ordinal not in range(128)
I've checked the files I've made changes to, but these seem fine.
Does anyone know where I can start to debug this issue? I'm relatively new to Python and debugging/understanding this trace is something I'm not familiar with.
So you have to use unicode strings because when your string is processed, somewhere it needs to use it as unicode, and it fails because the string type is str. You can make it into unicode by
mystring = unicode(mystring, 'utf-8')
This will change the type of your string from str to unicode
Related
all modules has been installed correctly since I restored it from a working backup.
the problem is, it doesn't read properly. does anyone know how to fix this?
2022-02-15 02:40:22,799 31154 ERROR tester werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/werkzeug/serving.py", line 205, in run_wsgi
execute(self.server.app)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/serving.py", line 193, in execute
application_iter = app(environ, start_response)
File "/home/ria/olive/tigernixerp11/odoo/service/server.py", line 292, in app
return self.app(e, s)
File "/home/ria/olive/tigernixerp11/odoo/service/wsgi_server.py", line 166, in application
return application_unproxied(environ, start_response)
File "/home/ria/olive/tigernixerp11/odoo/service/wsgi_server.py", line 154, in application_unproxied
result = handler(environ, start_response)
File "/home/ria/olive/tigernixerp11/odoo/http.py", line 1321, in __call__
return self.dispatch(environ, start_response)
File "/home/ria/olive/tigernixerp11/odoo/http.py", line 1295, in __call__
return self.app(environ, start_wrapped)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/wsgi.py", line 599, in __call__
return self.app(environ, start_response)
File "/home/ria/olive/tigernixerp11/odoo/http.py", line 1510, in dispatch
result = ir_http._dispatch()
File "/home/ria/olive/tigernixerp11/addons/auth_signup/models/ir_http.py", line 19, in _dispatch
return super(Http, cls)._dispatch()
File "/home/ria/olive/tigernixerp11/addons/web_editor/models/ir_http.py", line 22, in _dispatch
return super(IrHttp, cls)._dispatch()
File "/home/ria/olive/tigernixerp11/addons/http_routing/models/ir_http.py", line 322, in _dispatch
rule, arguments = cls._find_handler(return_rule=True)
File "/home/ria/olive/tigernixerp11/odoo/addons/base/ir/ir_http.py", line 84, in _find_handler
return cls.routing_map().bind_to_environ(request.httprequest.environ).match(return_rule=return_rule)
File "/home/ria/olive/tigernixerp11/odoo/addons/base/ir/ir_http.py", line 238, in routing_map
cls._routing_map = http.routing_map(mods, False, converters=cls._get_converters())
File "/home/ria/olive/tigernixerp11/odoo/http.py", line 988, in routing_map
routing_map.add(werkzeug.routing.Rule(url, endpoint=endpoint, methods=routing['methods'], **kw))
File "/usr/local/lib/python3.6/dist-packages/werkzeug/routing.py", line 1197, in add
rule.bind(self)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/routing.py", line 681, in bind
self.compile()
File "/usr/local/lib/python3.6/dist-packages/werkzeug/routing.py", line 731, in compile
_build_regex(self.is_leaf and self.rule or self.rule.rstrip('/'))
File "/usr/local/lib/python3.6/dist-packages/werkzeug/routing.py", line 721, in _build_regex
variable, converter, c_args, c_kwargs)
File "/usr/local/lib/python3.6/dist-packages/werkzeug/routing.py", line 689, in get_converter
raise LookupError('the converter %r does not exist' % converter_name)
LookupError: the converter 'str' does not exist
restoring in another computer doesn't seem to have any problem butthis computer seems to be unable to read properly
This question already has an answer here:
gethostbyaddr() raises UnicodeDecodeError in Python 3 [duplicate]
(1 answer)
Closed 2 years ago.
I installed the latest version of Flask (flask-1.1.2) using pip.
I have a simple code and I named the file 'hello.py':
from flask import Flask
app = Flask(__name__)
#app.route('/')
def hello_world():
return 'Hello, World!'
After that, I used two commands:
set FLASK_APP=hello.py
flask run
and saw this:
(env) C:\Users\Admin\Desktop\flask>flask run
* Serving Flask app "hello.py"
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Debug mode: off
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Admin\Desktop\flask\env\Scripts\flask.exe\__main__.py", line 7, in <module>
File "c:\users\admin\desktop\flask\env\lib\site-packages\flask\cli.py", line 967, in main
cli.main(args=sys.argv[1:], prog_name="python -m flask" if as_module else None)
File "c:\users\admin\desktop\flask\env\lib\site-packages\flask\cli.py", line 586, in main
return super(FlaskGroup, self).main(*args, **kwargs)
File "c:\users\admin\desktop\flask\env\lib\site-packages\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\users\admin\desktop\flask\env\lib\site-packages\click\core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\admin\desktop\flask\env\lib\site-packages\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\admin\desktop\flask\env\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\admin\desktop\flask\env\lib\site-packages\click\decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "c:\users\admin\desktop\flask\env\lib\site-packages\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\admin\desktop\flask\env\lib\site-packages\flask\cli.py", line 852, in run_command
run_simple(
File "c:\users\admin\desktop\flask\env\lib\site-packages\werkzeug\serving.py", line 1052, in run_simple
inner()
File "c:\users\admin\desktop\flask\env\lib\site-packages\werkzeug\serving.py", line 996, in inner
srv = make_server(
File "c:\users\admin\desktop\flask\env\lib\site-packages\werkzeug\serving.py", line 847, in make_server
return ThreadedWSGIServer(
File "c:\users\admin\desktop\flask\env\lib\site-packages\werkzeug\serving.py", line 740, in __init__
HTTPServer.__init__(self, server_address, handler)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\socketserver.py", line 452, in __init__
self.server_bind()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\http\server.py", line 140, in server_bind
self.server_name = socket.getfqdn(host)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\socket.py", line 756, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 6: invalid continuation byte
Found the problem. I just have cyrilic signs in computer name
I'm trying to run two instances of OpenERP on the same machine, but whenever I launch the second one it crashes. It is the same user that is launching the two instances of OpenERP and in the same postgresDB but, I launch each instance of OpenERP with different users in the database. Here is the log file I have no idea what is going on here:
Traceback (most recent call last):
File "/home/user/lib/python2.7/Werkzeug-0.9.4-py2.7.egg/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/home/user/lib/python2.7/Werkzeug-0.9.4-py2.7.egg/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/home/user/openerp-8.0-acmlpsc/openerp8/openerp/service/server.py", line 273, in app
return self.app(e, s)
File "/home/user/openerp-8.0-acmlpsc/openerp8/openerp/service/wsgi_server.py", line 215, in application
return application_unproxied(environ, start_response)
File "/home/user/openerp-8.0-acmlpsc/openerp8/openerp/service/wsgi_server.py", line 201, in application_unproxied
result = handler(environ, start_response)
File "/home/user/openerp-8.0-acmlpsc/openerp8/openerp/http.py", line 1097, in __call__
return self.dispatch(environ, start_response)
File "/home/user/openerp-8.0-acmlpsc/openerp8/openerp/http.py", line 1074, in __call__
return self.app(environ, start_wrapped)
File "/home/user/lib/python2.7/Werkzeug-0.9.4-py2.7.egg/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/home/user/openerp-8.0-acmlpsc/openerp8/openerp/http.py", line 1226, in dispatch
ir_http = request.registry['ir.http']
File "/home/user/openerp-8.0-acmlpsc/openerp8/openerp/http.py", line 220, in registry
return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None
File "/home/user/openerp-8.0-acmlpsc/openerp8/openerp/modules/registry.py", line 269, in get
update_module)
File "/home/user/openerp-8.0-acmlpsc/openerp8/openerp/modules/registry.py", line 299, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/user/openerp-8.0-acmlpsc/openerp8/openerp/modules/loading.py", line 335, in load_modules
force, status, report, loaded_modules, update_module)
File "/home/user/openerp-8.0-acmlpsc/openerp8/openerp/modules/loading.py", line 241, in load_marked_modules
graph.add_modules(cr, module_list, force)
File "/home/user/openerp-8.0-acmlpsc/openerp8/openerp/modules/graph.py", line 99, in add_modules
info = openerp.modules.module.load_information_from_description_file(module)
File "/home/user/openerp-8.0-acmlpsc/openerp8/openerp/modules/module.py", line 180, in load_information_from_description_file
terp_file = opj(mod_path, '__openerp__.py')
File "/usr/local/lib/python2.7/posixpath.py", line 77, in join
elif path == '' or path.endswith('/'):
AttributeError: 'bool' object has no attribute 'endswith'
I hope you can help me.
This may be due to port clash. Try running the instances on different ports, say one on 8069 and the other on 8070.
Try opening the instances in separate Icognito Window (while using chrome), or Private Browsing Window(while using mozilla), because there may be case of one instance overwriting the sessions of another openerp instance.
If this doesn't solve your problem, then I suggest you to pull the latest code of OpenERP8, as still it is not stable.
Hope this helps, do update me with your feedback..
When I starts Python 2.7+Django app and try to go http://127.0.0.1:8000/admin/ I see only text without normal display.
It happens only winth Python 2.7. When I use Python 3.3 everything is OK. But I need exactly Python 2.7.
Here is my errors
[19/Mar/2014 12:39:00] "GET /admin/ HTTP/1.1" 200 2990
Traceback (most recent call last):
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 68, in __call__
return super(StaticFilesHandler, self).__call__(environ, start_response)
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 206, in __call__
response = self.get_response(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 58, in get_response
return self.serve(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 51, in serve
return serve(request, self.file_path(request.path), insecure=True)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\views.py", line 41, in serve
return static.serve(request, path, document_root=document_root, **kwargs)
File "C:\Python27\lib\site-packages\django\views\static.py", line 61, in serve
content_type, encoding = mimetypes.guess_type(fullpath)
File "C:\Python27\lib\mimetypes.py", line 297, in guess_type
init()
File "C:\Python27\lib\mimetypes.py", line 358, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 258, in read_windows_registry
for subkeyname in enum_types(hkcr):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd8 in position 0: ordinal not in range(128)
Traceback (most recent call last):
File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 68, in __call__
return super(StaticFilesHandler, self).__call__(environ, start_response)
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 206, in __call__
response = self.get_response(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 58, in get_response
return self.serve(request)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 51, in serve
return serve(request, self.file_path(request.path), insecure=True)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\views.py", line 41, in serve
return static.serve(request, path, document_root=document_root, **kwargs)
File "C:\Python27\lib\site-packages\django\views\static.py", line 61, in serve
content_type, encoding = mimetypes.guess_type(fullpath)
File "C:\Python27\lib\mimetypes.py", line 297, in guess_type
init()
File "C:\Python27\lib\mimetypes.py", line 358, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 258, in read_windows_registry
for subkeyname in enum_types(hkcr):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd8 in position 0: ordinal not in range(128)
Help me please!
you can use vim or other text editor which can tell the 16bit coding check the view and the template file again.I
I find answer! It needed create file sitecustomize.py C:\Python27\Lib\site-packages.
And write there:
import sys
sys.setdefaultencoding("cp1251")
And all works)
In test server it is working. But production gives this traceback:
what different? And what does that error mean?
Different is only in python versions. In test server it is 2.6.5 and production 2.5.2. How can I get rid of this error with out changing version?
True
2008-10-16 15:20:00
- did not match our database
Traceback (most recent call last):
File "./mr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/django/core/management/base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/django/core/management/base.py", line 222, in execute
output = self.handle(*args, **options)
File "/usr/local/cluster/dynamic/website/video/remmedia/management/commands/remmedia.py", line 50, in handle
self.FirstTimeLoad()
File "/usr/local/cluster/dynamic/website/video/remmedia/management/commands/remmedia.py", line 117, in FirstTimeLoad
med,created=RemMedia.objects.get_or_create(index=program.Id+50000000, defaults=fields)
File "/usr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/django/db/models/manager.py", line 123, in get_or_create
return self.get_query_set().get_or_create(**kwargs)
File "/usr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/django/db/models/query.py", line 335, in get_or_create
obj.save(force_insert=True)
File "/usr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/django/db/models/base.py", line 410, in save
self.save_base(force_insert=force_insert, force_update=force_update)
File "/usr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/django/db/models/base.py", line 495, in save_base
result = manager._insert(values, return_id=update_pk)
File "/usr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/django/db/models/manager.py", line 177, in _insert
return insert_query(self.model, values, **kwargs)
File "/usr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/django/db/models/query.py", line 1087, in insert_query
return query.execute_sql(return_id)
File "/usr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/django/db/models/sql/subqueries.py", line 320, in execute_sql
cursor = super(InsertQuery, self).execute_sql(None)
File "/usr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/django/db/models/sql/query.py", line 2369, in execute_sql
cursor.execute(sql, params)
File "/usr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/django/db/backends/mysql/base.py", line 84, in execute
return self.cursor.execute(query, args)
File "/usr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/MySQLdb/cursors.py", line 158, in execute
query = query % db.literal(args)
File "/usr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/MySQLdb/connections.py", line 265, in literal
return self.escape(o, self.encoders)
File "/usr/local/cluster/dynamic/virtualenv/lib/python2.5/site-packages/MySQLdb/connections.py", line 198, in string_literal
return db.string_literal(obj)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-10: ordinal not in range(128)
After some time thinking and testing. I notice that error shows only when i do this:
med,created=RemMedia.objects.get_or_create(index=program.Id+50000000, defaults=fields)
After some more time of thinking end testing, i found the error. It is in dictionary fields. There is one variable which i get from BeautifulSoup the code looks like:
soup=BeautifulSoup(program.Description.encode('utf-8'))
name=soup.find('div',{'class':'head'})
fields=dict(
name=name.string,
description=program.Description.encode('utf-8'),
program_name=program.Name.encode('utf-8'),
program_date_time=program.RealDateTime,
topic_data_time=program.RealDateTime,
topic_tag='',
created=program.Updated,
media=media
)
The problem is with variable name in fields dictionary.
Question remain : How to convert it so it will not gives an error?
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-10: ordinal not in range(128)
Do you have a character with an ascii value > 128? Probably an accented letter.
http://www.asciitable.com/
If the problem lies within the database, it's probably a setting. If it's within the python code, you may try placing this line at the top of your python file that deals with the string.
# coding:utf-8