Skip to content

Parse json from kernelspec being printed with warnings #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions jupyter-kernelspec.el
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,17 @@ REFRESH."
(or (and (not refresh) (gethash host jupyter--kernelspecs))
(let ((specs
(plist-get
(let ((json (or (jupyter-command "kernelspec" "list"
(let* ((json-result (or (jupyter-command "kernelspec" "list"
"--json" "--log-level" "ERROR")
(error "\
Can't obtain kernelspecs from jupyter shell command"))))
Can't obtain kernelspecs from jupyter shell command")))
(_ (string-match "{\\(.\\|\n\\)*}" json-result))
(json-start (car (match-data)))
(json-end (cadr (match-data)))
(json (substring json-result json-start json-end)))
(when (> json-start 0)
(warn "Getting kernelspec has warning(s):"
(substring json-result 0 json-start)))
(condition-case nil
(jupyter-read-plist-from-string json)
(error
Expand Down