You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there,
I recently found the bug in RESTful-API
I have got the latest version of glances from python3-pip installer
When I start the webserver via: glances -w -p 8282
And access the RESTful-API: localhost:8282/api/3/network/interface_name (the one I just copied from https://github.com/nicolargo/glances/wiki/The-Glances-RESTFULL-JSON-API), I got the 500 Internal Server Error
Read the Trace back log: Traceback (most recent call last): File "/home/vinhloiit/glances/env/bin/bottle.py", line 862, in _handle return route.call(**args) File "/home/vinhloiit/glances/env/bin/bottle.py", line 1740, in wrapper rv = callback(*a, **ka) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 619, in _enable_cors return fn(*args, **kwargs) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 45, in wrapper ret = func(*args, **kwargs) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 499, in _api_item return self._api_itemvalue(plugin, item) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 45, in wrapper ret = func(*args, **kwargs) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 473, in _api_itemvalue ret = self.stats.get_plugin(plugin).get_stats_item(item) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/plugins/glances_plugin.py", line 393, in get_stats_item return self._json_dumps({item: map(itemgetter(item), self.stats)}) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/plugins/glances_plugin.py", line 148, in _json_dumps return json.dumps(d) File "/usr/lib/python3.6/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "/usr/lib/python3.6/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/usr/lib/python3.6/json/encoder.py", line 180, in default o.__class__.__name__) TypeError: Object of type 'map' is not JSON serializable
Description
Hi there,
I recently found the bug in RESTful-API
I have got the latest version of glances from python3-pip installer
When I start the webserver via:
glances -w -p 8282
And access the RESTful-API:
localhost:8282/api/3/network/interface_name
(the one I just copied from https://github.com/nicolargo/glances/wiki/The-Glances-RESTFULL-JSON-API), I got the500 Internal Server Error
Read the Trace back log:
Traceback (most recent call last): File "/home/vinhloiit/glances/env/bin/bottle.py", line 862, in _handle return route.call(**args) File "/home/vinhloiit/glances/env/bin/bottle.py", line 1740, in wrapper rv = callback(*a, **ka) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 619, in _enable_cors return fn(*args, **kwargs) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 45, in wrapper ret = func(*args, **kwargs) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 499, in _api_item return self._api_itemvalue(plugin, item) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 45, in wrapper ret = func(*args, **kwargs) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/outputs/glances_bottle.py", line 473, in _api_itemvalue ret = self.stats.get_plugin(plugin).get_stats_item(item) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/plugins/glances_plugin.py", line 393, in get_stats_item return self._json_dumps({item: map(itemgetter(item), self.stats)}) File "/home/vinhloiit/glances/env/lib/python3.6/site-packages/glances/plugins/glances_plugin.py", line 148, in _json_dumps return json.dumps(d) File "/usr/lib/python3.6/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "/usr/lib/python3.6/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib/python3.6/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/usr/lib/python3.6/json/encoder.py", line 180, in default o.__class__.__name__) TypeError: Object of type 'map' is not JSON serializable
Well, the error from
map
in_json_dumps
inglances_plugin.py
, I found on https://stackoverflow.com/questions/33989430/map-object-is-not-json-serializable and see that thismap
is not the same as python 2Versions
Glances & psutil (glances -V):
Glances v3.1.0 with psutil v5.4.8
Operating System (lsb_release -a):
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
Logs
https://pastebin.com/1hF1fSNy
The text was updated successfully, but these errors were encountered: