Merge pull request #553 from dickmao/issue-552-command

Do not assume "notebook" subcommand
This commit is contained in:
John Miller 2019-06-05 15:02:21 -05:00 committed by GitHub
commit 2207014453
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 12 deletions

View file

@ -99,6 +99,17 @@ Scenario: Bad curl invocation produces sensible error message
Scenario: jupyter not found
And I start bad jupyter path
@jupyter-notebook
Scenario: Someone uses jupyter-notebook
Given I customize "ein:jupyter-default-server-command" to "jupyter-notebook"
And I set "ein:jupyter-server-use-subcommand" to eval "nil"
Given I start and login to the server configured "\n"
And I switch to log expr "ein:log-all-buffer-name"
Then I should not see "[warn]"
And I should not see "[error]"
And I customize "ein:jupyter-default-server-command" to "jupyter"
And I set "ein:jupyter-server-use-subcommand" to "notebook"
@login
Scenario: With token server
Given I start and login to the server configured "\n"

View file

@ -408,6 +408,10 @@
(let ((member-p (member value (symbol-value (intern variable)))))
(if negate (should-not member-p) (should member-p)))))
(When "^I customize \"\\(.+\\)\" to \"\\(.+\\)\"$"
(lambda (variable value)
(custom-set-variables `(,(intern variable) ,value t))))
(When "^I set \"\\(.+\\)\" to \"\\(.+\\)\"$"
(lambda (variable value)
(set (intern variable) value)))

View file

@ -61,14 +61,6 @@ Notebook server."
(const :tag "First value of `ein:url-or-port'" nil))
:group 'ein)
(defcustom ein:jupyter-default-server-command "jupyter"
"The default command to start a jupyter notebook server.
It is used when the `ein:jupyter-server-start' command is
interactively called."
:group 'ein
:type '(file))
(defcustom ein:filename-translations nil
"Convert file paths between Emacs and Python process.

View file

@ -57,6 +57,23 @@ the notebook directory, you can set it here for future calls to
(defvar *ein:last-jupyter-command* nil)
(defvar *ein:last-jupyter-directory* nil)
(defcustom ein:jupyter-default-server-command "jupyter"
"The default command to start a jupyter notebook server.
Changing this to `jupyter-notebook' requires customizing `ein:jupyter-server-use-subcommand' to nil.
"
:group 'ein
:type '(file)
:set (lambda (symbol value)
(set-default symbol value)
(setq *ein:last-jupyter-command* nil)))
(defcustom ein:jupyter-server-use-subcommand "notebook"
"Users of \"jupyter-notebook\" (as opposed to \"jupyter notebook\") need to `Omit'."
:group 'ein
:type '(choice (string :tag "Subcommand" "notebook")
(const :tag "Omit" nil)))
(defsubst ein:jupyter-server-process ()
"Return the emacs process object of our session"
(get-buffer-process (get-buffer ein:jupyter-server-buffer-name)))
@ -64,10 +81,10 @@ the notebook directory, you can set it here for future calls to
(defun ein:jupyter-server--run (buf cmd dir &optional args)
(when ein:debug
(add-to-list 'ein:jupyter-server-args "--debug"))
(let* ((vargs (append (if dir
`("notebook"
,(format "--notebook-dir=%s"
(convert-standard-filename dir))))
(unless (stringp dir)
(error "ein:jupyter-server--run: notebook directory required"))
(let* ((vargs (append (ein:aif ein:jupyter-server-use-subcommand (list it))
(list (format "--notebook-dir=%s" (convert-standard-filename dir)))
args
ein:jupyter-server-args))
(proc (apply #'start-process