cytoscape / py2cytoscape

Python utilities for Cytoscape and Cytoscape.js
https://py2cytoscape.readthedocs.io
MIT License
178 stars 45 forks source link

CyRestClient.style ignores custom ip/port settings #29

Closed thomaskelder closed 6 years ago

thomaskelder commented 7 years ago

I'm trying to set styles using py2cytoscape on a Cytoscape instance running on another url than http://localhost:1234. The CyRestClient provides a way to enter a custom ip/port, but the styles seem to always use the default "localhost".

Small snippet to reproduce (Cytoscape itself should be listening on 172.17.0.1):

from py2cytoscape.data.cyrest_client import CyRestClient
cy = CyRestClient(ip='172.17.0.1', port=1234)

style = cy.style.create('basic')
defaults = { 'NODE_SIZE': 12 }
style.update_defaults(defaults)

This gives me an error indicating that it is trying to connect to localhost instead of 172.17.0.1:

ConnectionError: HTTPConnectionPool(host='localhost', port=1234): Max retries exceeded with url: /v1/styles/basic/defaults (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f3eeb6c1860>: Failed to establish a new connection: [Errno 111] Connection refused',))

A workaround is to manually set the BASE_URL:

from py2cytoscape.data.cyrest_client import CyRestClient
cy = CyRestClient(ip='172.17.0.1', port=1234)

style = cy.style.create('basic')
style._Style__url = 'http://172.17.0.1:1234/v1/styles/basic/'
defaults = { 'NODE_SIZE': 12 }
style.update_defaults(defaults)

Then it works without error.

jorgeboucas commented 6 years ago

deprecated

please use the new py2cytoscape.cyrest module