Commit e58b8b27 authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

Remove references to 'guix-kernel exceptions.

* guix-jupyter-kernel.scm (error->shtml, error->html): Remove.
(reply-execute-request): Remove catch for 'guix-kernel exceptions.
parent e1cea845
......@@ -87,17 +87,6 @@
(lambda (port)
(sxml->xml sxml port))))
(define (error->shtml error)
(match error
(('guix-kernel msg errno)
`(h3 (@ (style "color: red;"))
,(string-append "Error: " msg)))
(_
`(h3 (@ (style "color: red;"))
"Error !"))))
(define (error->html error)
(sxml->html-string (error->shtml error)))
;;
;; Handlers.
......@@ -229,79 +218,74 @@ to KERNEL as a reply to MESSAGE, and return STATE suitably adjusted."
(code (assoc-ref (json-string->scm content) "code"))
(magic (get-magic-line code))
(count (proxy-state-execution-count state)))
(catch 'guix-kernel
(λ ()
(cond
((magic-env? code)
(pub-busy kernel message)
(match (string-tokenize magic)
((_ "environment" name "<-" specs ...)
(match (lookup-proxied name state)
(#f
(create-environment name specs state
#:kernel kernel
#:message message))
((? kernel? proxy)
(format/log "terminating existing '~a' environment~%"
name)
(unmonitor-client proxy)
(terminate-proxied-kernel proxy)
(create-environment name specs
(unregister-proxied name state)
#:kernel kernel
#:message message))))
((_ "environment" name)
(match (lookup-proxied name state)
(#f
(reply-html kernel message
(sxml->html-string
`(bold "Unknown environment "
(code ,name) "."))
count)
(increment-execution-count state))
((? kernel? proxy)
(format/log "evaluating code in container ~s (PID ~s)~%"
name (kernel-pid proxy))
(send-message proxy message)
(let ((state (increment-execution-count state)))
(set-proxy-state-default-environment state name)))))
((lst ...)
(reply-html kernel message
(sxml->html-string
`(bold "Invalid " (code "guix environment")
" magic."))
count)
(increment-execution-count state))))
((magic-html? code)
(reply-html kernel message (delete-magic code) count)
(increment-execution-count state))
((proxy-state-default-environment state)
=>
(lambda (environment)
(let ((proxied (lookup-proxied environment state)))
(format/log "evaluating code in environment ~s (PID ~s)~%"
environment (kernel-pid proxied))
(send-message proxied message
#:kernel-socket kind)
(increment-execution-count state))))
(else
(reply-html kernel message
(sxml->html-string
`(div "You have not selected an execution environment
(cond
((magic-env? code)
(pub-busy kernel message)
(match (string-tokenize magic)
((_ "environment" name "<-" specs ...)
(match (lookup-proxied name state)
(#f
(create-environment name specs state
#:kernel kernel
#:message message))
((? kernel? proxy)
(format/log "terminating existing '~a' environment~%"
name)
(unmonitor-client proxy)
(terminate-proxied-kernel proxy)
(create-environment name specs
(unregister-proxied name state)
#:kernel kernel
#:message message))))
((_ "environment" name)
(match (lookup-proxied name state)
(#f
(reply-html kernel message
(sxml->html-string
`(bold "Unknown environment "
(code ,name) "."))
count)
(increment-execution-count state))
((? kernel? proxy)
(format/log "evaluating code in container ~s (PID ~s)~%"
name (kernel-pid proxy))
(send-message proxy message)
(let ((state (increment-execution-count state)))
(set-proxy-state-default-environment state name)))))
((lst ...)
(reply-html kernel message
(sxml->html-string
`(bold "Invalid " (code "guix environment")
" magic."))
count)
(increment-execution-count state))))
((magic-html? code)
(reply-html kernel message (delete-magic code) count)
(increment-execution-count state))
((proxy-state-default-environment state)
=>
(lambda (environment)
(let ((proxied (lookup-proxied environment state)))
(format/log "evaluating code in environment ~s (PID ~s)~%"
environment (kernel-pid proxied))
(send-message proxied message
#:kernel-socket kind)
(increment-execution-count state))))
(else
(reply-html kernel message
(sxml->html-string
`(div "You have not selected an execution environment
yet. You can create one by entering a “magic command” in a cell as follows:"
(p (code ";;guix environment my-environment <- \
(p (code ";;guix environment my-environment <- \
python-ipython python-ipykernel"))
"You can then select a kernel and hand it code
"You can then select a kernel and hand it code
to execute:"
(p (pre
(code
";;guix kernel my-environment ipython\n"
"2 + 2")))))
count)
state)))
(λ error
(reply-html kernel message (error->html error) count)
(increment-execution-count state)))))
(p (pre
(code
";;guix kernel my-environment ipython\n"
"2 + 2")))))
count)
state))))
(define (shutdown kernel kind message state)
(format/log "shutting down ~a containers~%"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment