cytoscape / py4cytoscape

Python library for calling Cytoscape Automation via CyREST
https://Py4Cytoscape.readthedocs.io
Other
72 stars 15 forks source link

import_network_from_file() fails if file name contains space followed by equal symbol #70

Open coleslaw481 opened 3 years ago

coleslaw481 commented 3 years ago

import_network_from_file() fails if the file name contains space followed by an equal symbol: hello =there.cx

This is on a Mac with big sur 11.6 and using py4cytoscape 0.0.11 with Python version 3.7.3

hello =there.cx.zip

To reproduce unzip the attached file, open a python terminal with current working directory set to directory with hello =there.cx file and run the following:

import os
import py4cytoscape as py4
py4.import_network_from_file(os.path.abspath('hello =there.cx'))

Error seen:

n commands_post(): Error processing arguments: String index out of range: 0
Traceback (most recent call last):
  File "/Users/churas/anaconda3/envs/networkx2/lib/python3.7/site-packages/py4cytoscape/commands.py", line 390, in commands_post
    r.raise_for_status()
  File "/Users/churas/anaconda3/envs/networkx2/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: http://127.0.0.1:1234/v1/commands/network/load%20file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/churas/anaconda3/envs/networkx2/lib/python3.7/site-packages/py4cytoscape/py4cytoscape_logger.py", line 133, in wrapper_log
    log_exception(func, e)
  File "/Users/churas/anaconda3/envs/networkx2/lib/python3.7/site-packages/py4cytoscape/py4cytoscape_logger.py", line 130, in wrapper_log
    value = func(*args, **kwargs) # Call function being logged
  File "/Users/churas/anaconda3/envs/networkx2/lib/python3.7/site-packages/py4cytoscape/networks.py", line 1265, in import_network_from_file
    res = commands.commands_post(f'network load file file="{file}"', base_url=base_url)
  File "/Users/churas/anaconda3/envs/networkx2/lib/python3.7/site-packages/py4cytoscape/py4cytoscape_logger.py", line 133, in wrapper_log
    log_exception(func, e)
  File "/Users/churas/anaconda3/envs/networkx2/lib/python3.7/site-packages/py4cytoscape/py4cytoscape_logger.py", line 130, in wrapper_log
    value = func(*args, **kwargs) # Call function being logged
  File "/Users/churas/anaconda3/envs/networkx2/lib/python3.7/site-packages/py4cytoscape/commands.py", line 396, in commands_post
    _handle_error(e)
  File "/Users/churas/anaconda3/envs/networkx2/lib/python3.7/site-packages/py4cytoscape/commands.py", line 682, in _handle_error
    raise e
py4cytoscape.exceptions.CyError: In commands_post(): Error processing arguments: String index out of range: 0
bdemchak commented 3 years ago

Thanks, Chris ... I have little doubt that this is a legit problem. Encoding is a funny thing, and it's a fair bit that I didn't get it all correct. I'll look into this.