pygephi_graphstreaming icon indicating copy to clipboard operation
pygephi_graphstreaming copied to clipboard

Websocket client and native python3 compatability.

Open scholer opened this issue 10 years ago • 2 comments

Hi, I have created a module, websocket_client.py, that uses websocket to communicate with the Gephi graph-streaming server. Would you be interested in merging this into your main repository? And thanks for creating this nice python module :) ---Rasmus

scholer avatar Oct 04 '15 22:10 scholer

Thanks a lot Rasmus for your contribution, I will merge your pull request to the repository.

Before that, could you confirm this? It depends on the python package websocket-client: https://github.com/liris/websocket-client The package can also be installed through pip install websocket-client

I've tested the implementation with the examples, and in order to change the client to use websockets, you need to import websocket_client, create a GephiWsClient and use a ws:// url:

from pygephi import websocket_client

g = websocket_client.GephiWsClient('ws://localhost:8080/workspace0', autoflush=True)

panisson avatar Oct 07 '15 15:10 panisson

Hi André, Thank you for you response - and please let me know if you want me to clean up anything before the merge. Note that in my branch I also removed the import check for json and fallback to simplejson. It is my understanding that this is only relevant for Python 2.5. If you want/need to maintain Python 2.5 support, I can add the import check and fallback back in.

Yes, you are correct on all accounts, both regarding the websocket-client package and using ws:// as the url scheme. This is the default for the sub-class, so the client can be used as:

from pygephi.websocket_client import GephiWsClient
g = GephiWsClient(autoflush=True)

Regarding the websocket-client package, it should be easy to use any of the common python websocket packages - e.g. autobahn, ws4py, websockets or websocket-client. These provide different features and uses different frameworks for e.g. async io, so in theory a user could have a good reason to pick another websocket package than websocket-client. I didn't want to add that choice now, since it will only add code that may not ever be used by anyone. But if you ever get a user request for support for another websocket package, feel free to ping me and I will happily contribute to the implementation.

scholer avatar Oct 09 '15 15:10 scholer