GithubHelp home page GithubHelp logo

Comments (12)

pybokeh avatar pybokeh commented on June 2, 2024

To make it work for me, I changed line 90 in server.py from:

data = data.encode('latin-1')

to

data = data.encode('utf-8')

I'm not a developer and only have intermediate Python knowledge. So not sure if this is the proper solution or if it works with Python 2.X also.

from remi.

dddomodossola avatar dddomodossola commented on June 2, 2024

Hi pybokeh. First of all thank you for your exhaustive report. I'm unable to reproduce the error and furthermore, the code line you changed applies only to python version less than 3. Considering you are working with 3.4, the encoding you changed should not take effect.
Maybe the detection of python version on your enviroment is faulty?

May I ask you to do this test?

import sys
sys.version_info < (3,)

from remi.

pybokeh avatar pybokeh commented on June 2, 2024

@dddomodossola

import sys
sys.version_info < (3,)

It outputs "False"

from remi.

pybokeh avatar pybokeh commented on June 2, 2024

@dddomodossola
My sample NBA sqlite3 database can be downloaded from here There is a cross symbol † in the player name. This cross symbol is apparently the character that is causing problems.

from remi.

dddomodossola avatar dddomodossola commented on June 2, 2024

@pybokeh
Yeah, I've seen. Your solution to the problem works fine, but I'm trying to solve this also for version less than 3.

from remi.

dddomodossola avatar dddomodossola commented on June 2, 2024

@pybokeh
Now should be fixed. Can you run your example with python2.7 ?
Thank you so much for your help.

from remi.

pybokeh avatar pybokeh commented on June 2, 2024

Error: UnicodeEncodeError: 'ascii' codec can't encode character u'\u2020' in position 14: ordinal not in range(128)

full traceback:
Traceback (most recent call last):
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/SocketServer.py", line 599, in process_request_thread
self.finish_request(request, client_address)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "test.py", line 10, in init
super(MyApp, self).init(_args)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/SocketServer.py", line 655, in init
self.handle()
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
method()
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/server.py", line 552, in do_GET
self.process_all(path)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/server.py", line 562, in process_all
self.client.root = self.main(_self.server.userdata)
File "test.py", line 62, in main
item.append(str(id(item)), str(row_item))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2020' in position 14: ordinal not in range(128)

I installed remi via pip:
pip install git+https://github.com/dddomodossola/remi.git

So I'm assuming your latest patch was implement.
Python version 2.7.10 virtual environment installed with conda.

from remi.

dddomodossola avatar dddomodossola commented on June 2, 2024

The problem seems to be the str() conversion you are doing. Should be:

item.append(str(id(item)), row_item)

from remi.

pybokeh avatar pybokeh commented on June 2, 2024

My database query can return data that are of type int. So herein lies the problem. Your item.append() calls the html conversion code which calls s.repr() method. An int doesn't have repr(). That is why I am forced to convert the table item to str.

Below is the traceback when I don't ensure the table item is of type str:
Traceback (most recent call last):
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/SocketServer.py", line 599, in process_request_thread
self.finish_request(request, client_address)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "test.py", line 10, in init
super(MyApp, self).init(*args)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/SocketServer.py", line 655, in init
self.handle()
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/BaseHTTPServer.py", line 340, in handle
self.handle_one_request()
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
method()
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/server.py", line 552, in do_GET
self.process_all(path)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/server.py", line 571, in process_all
html = self.client.root.repr(self.client)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/gui.py", line 196, in repr
return super(Widget,self).repr(client, include_children)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/gui.py", line 97, in repr
innerHTML = innerHTML + s.repr(client)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/gui.py", line 196, in repr
return super(Widget,self).repr(client, include_children)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/gui.py", line 97, in repr
innerHTML = innerHTML + s.repr(client)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/gui.py", line 196, in repr
return super(Widget,self).repr(client, include_children)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/gui.py", line 97, in repr
innerHTML = innerHTML + s.repr(client)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/gui.py", line 196, in repr
return super(Widget,self).repr(client, include_children)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/gui.py", line 97, in repr
innerHTML = innerHTML + s.repr(client)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/gui.py", line 196, in repr
return super(Widget,self).repr(client, include_children)
File "/home/pybokeh/miniconda3/envs/remipy2/lib/python2.7/site-packages/remi/gui.py", line 97, in repr
innerHTML = innerHTML + s.repr(client)
AttributeError: 'int' object has no attribute 'repr'

from remi.

dddomodossola avatar dddomodossola commented on June 2, 2024

You can do something like this:

item.append( str(id(item)), u"%s" % row_item )

from remi.

pybokeh avatar pybokeh commented on June 2, 2024

Thanks that worked. I'll have to do some studying on encodings. :-)

from remi.

dddomodossola avatar dddomodossola commented on June 2, 2024

It's the same for me ;-)
Thank you for the information you reported in this issue, you helped me a lot improving remi.

from remi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.