davidban77 / gns3fy

Python library wrapper around GNS3 Server REST API
https://davidban77.github.io/gns3fy/
57 stars 28 forks source link

Issue on closing project #71

Closed LucaV27 closed 4 years ago

LucaV27 commented 4 years ago

Hi, When i try to close a project, it gives me this error:

Traceback (most recent call last): File "/gns3api/test_gns3fy.py", line 46, in test_gns3() File "/gns3api/test_gns3fy.py", line 24, in test_gns3 project.close() File "/gns3api/venv/lib/python3.6/site-packages/gns3fy/gns3fy.py", line 1294, in close self._update(_response.json()) File "/gns3api/venv/lib/python3.6/site-packages/requests/models.py", line 898, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib/python3.6/json/init.py", line 354, in loads return _default_decoder.decode(s) File "/usr/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I'm using gns3fy v0.6.0 (on Python3.6.10) and gns3server v2.2.7

Krlosromero commented 4 years ago

hello,

Can you provide more information about what your script is doing?

Are you creating the object project and then opening the project first with project.open() ?

Have you tried running the script execution step by step on ipython or the pyhton interpreter ?

Please share more information about your issue

Regards!

LucaV27 commented 4 years ago

Hi, actually it's a pretty simple script...

gns3_server = gns3fy.Gns3Connector('http://localhost:3080')
project = gns3_server.get_project(project_id='f5fa7cc8-e998-4814-b30f-e68f30448531')['name']
test = gns3fy.Project(name=project, connector=gns3_server)
test.get()
test.open()
# time.sleep(1)
test.close()

BR

LucaV27 commented 4 years ago

Additionaly, I was checking the function close() in Project class of gns3fy.py

it gives error when it tries to handle the _response.json() object. It seems that the _response gives 204 response (as 'requests.models.Response'), but empty, so .json() function gives that error. To temporarily solve this issue i changed the function close() in Project class:

# self._update(_response.json())
self._update({"status": "closed"})

and it works. BR

davidban77 commented 4 years ago

Thanks, could be that they changed the response on the new version

davidban77 commented 4 years ago

Seems I might be able to create a patch soon

LucaV27 commented 4 years ago

Thanks a lot

davidban77 commented 4 years ago

Hey @LucaV27, should be fixed on 0.7.0 - can you take verify?

LucaV27 commented 4 years ago

Hi @davidban77! I could verify it. I will close the issue. Thanks