[vtkusers] Json object error caused by websocket.py

Aron Helser aron.helser at kitware.com
Tue Mar 20 13:34:44 EDT 2018


 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>
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> wrote:
>
>> ​​Hi Aron,
>>
>>
>> In the RemoteRenderer example https://www.vtk.org/Wiki/VTK/E
>> xamples/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>
>> *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/W
>> iki/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>
>> 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>
>>> 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>
>>>> *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>
>>>> 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
>>>>>
>>>>>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Regards,
>>>>>
>>>>>
>>>>> Zhuangming Shen
>>>>>
>>>>> _______________________________________________
>>>>> Powered by 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/20180320/c3232d98/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 40575 bytes
Desc: not available
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180320/c3232d98/attachment.png>


More information about the vtkusers mailing list