[vtkusers] Json object error caused by websocket.py

沈庄明 zhuangming.shen at sphic.org.cn
Tue Mar 20 21:05:10 EDT 2018


​Hi Aron,


Thanks for your explanation. It's clear now.



Regards,


Zhuangming Shen

________________________________
From: Aron Helser <aron.helser at kitware.com>
Sent: Wednesday, March 21, 2018 1:34 AM
To: 沈庄明
Cc: VTK Users
Subject: Re: [vtkusers] Json object error caused by websocket.py

Zhuangming ,
Regarding your original problem, I've found in the documentation that Python 3.6 supports json.loads() of 'bytes' type objects natively. That's the version I've been testing with.
https://docs.python.org/3.6/library/json.html

So your suggested fix is a good one, limited to python v3.4 and v3.5. I'll see if I can get it in.
Aron

On Tue, Mar 20, 2018 at 10:26 AM, Aron Helser <aron.helser at kitware.com<mailto:aron.helser at kitware.com>> wrote:
Thanks for the feedback! I've updated the wiki.

On Tue, Mar 20, 2018 at 4:51 AM, 沈庄明 <zhuangming.shen at sphic.org.cn<mailto:zhuangming.shen at sphic.org.cn>> wrote:

​​Hi Aron,


In the RemoteRenderer example https://www.vtk.org/Wiki/VTK/Examples/Python/Web/RemoteRenderer. If this code runs under VTK 8.1.0, I think


self.Application.GetObjectIdMap().SetActiveObject("VIEW", renderWindow)


should be changed to


self.initApplication().GetObjectIdMap().SetActiveObject("VIEW", renderWindow)


otherwise, an error will occur


AttributeError: '_WebCone' object has no attribute 'Application'​



Regards,


Zhuangming Shen

________________________________
From: Aron Helser <aron.helser at kitware.com<mailto:aron.helser at kitware.com>>
Sent: Sunday, March 18, 2018 5:03 AM
To: 沈庄明; VTK Users
Subject: Re: [vtkusers] Json object error caused by websocket.py

Were you referring to this VTK web example? https://www.vtk.org/Wiki/VTK/Examples/Python/Web/RemoteRenderer
This has been updated on the ParaViewWeb examples page for wslink: https://kitware.github.io/paraviewweb/examples/RemoteRenderer.html
As you can see it is very similar.

Hope that helps,
Aron

On Thu, Mar 15, 2018 at 9:30 PM, Aron Helser <aron.helser at kitware.com<mailto:aron.helser at kitware.com>> wrote:
Hi  Zhuangming,
(adding back the list)

We have tested wslink and vtk with python 3.5 and 3.6. They may use some features that require 3.5, but I'm not sure if there would be any issues with 3.4.

Which vtkweb example are you following? It is likely to be very similar with wslink - we designed it to require very few changes from the previous implementation.

Regards,
Aron

On Thu, Mar 15, 2018 at 4:50 AM, 沈庄明 <zhuangming.shen at sphic.org.cn<mailto:zhuangming.shen at sphic.org.cn>> wrote:

​Hi Aron,


Sorry for interrupting you again. I'm learning how to use wslink in my project. My project is coded using previous vtkweb framework, and learn a lot from its simple example to display a cone on the browse. Now I would like to use wslink, which can support python 3.x, to replace the old framework. I am not sure if you could provide me a similar simple example. Then I could learn by myself how to do that. Thanks in advance.



Regards,


Zhuangming Shen

________________________________
From: Aron Helser <aron.helser at kitware.com<mailto:aron.helser at kitware.com>>
Sent: Wednesday, March 14, 2018 11:51 PM
To: 沈庄明
Subject: Re: [vtkusers] Json object error caused by websocket.py

Thanks for the report - we've tested with Python 3.6, but I'm not sure there's automated testing for this code.
If you'd like to report a bug, that'd be great.

Thanks!
Aron

On Wed, Mar 14, 2018 at 4:11 AM, 沈庄明 <zhuangming.shen at sphic.org.cn<mailto:zhuangming.shen at sphic.org.cn>> wrote:

Hi all,


I found there probably be a bug around Line 250 in <VTK_build>/Wrapping/Python/wslink/websocket.py. If this code is run using python 3.x, this will cause an error "json object must be str not 'bytes' " when use json.loads. To avoid this error, I think the code can be modified by

​

[cid:b10da89b-5d6c-40ac-898d-8db128fb6001]



Regards,


Zhuangming Shen

_______________________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180321/626457db/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 40575 bytes
Desc: pastedImage.png
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180321/626457db/attachment-0001.png>


More information about the vtkusers mailing list