emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ob-python.el: Fix issue with sessions on remote machines
@ 2020-08-17 18:47 Christian Vanderwall
  2020-08-18 14:21 ` Jack Kamm
  0 siblings, 1 reply; 8+ messages in thread
From: Christian Vanderwall @ 2020-08-17 18:47 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]

The function `org-babel-python-evaluate-session' doesn't process temp
file names with `org-babel-process-file-name' before inserting them into
the Python code blocks. This causes a 'No such file' error when the
executing the code blocks on a remote directory.

The attached patch fixes this issue, allowing compilation of Python
source blocks with a remote directory, such as :dir /ssh:user@server:/.

This is my first patch ever, so please let me know if there's ways I can
improve.

Thanks!
-- 
Christian Vanderwall

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ob-python.el-Fix-issue-with-sessions-on-remote-machi.patch --]
[-- Type: text/x-patch, Size: 1626 bytes --]

From 7cf3d4c53e12addced7d2f65de1632971f44f056 Mon Sep 17 00:00:00 2001
From: Christian Vanderwall <christian@cvdub.net>
Date: Tue, 11 Aug 2020 20:26:39 -0700
Subject: [PATCH] ob-python.el: Fix issue with sessions on remote machines

* lisp/ob-python.el (org-babel-python-evaluate-session): Process
temporary file name with `org-babel-process-file-name' before
inserting it into code Python code snippets.

Before this change, the entire temporary filename was sent to the
Python session for execution, causing a 'No such file' error when the
filename had a Tramp format such as
/ssh:user@server:/tmp/python-ABCDEF.

TINYCHANGE
---
 lisp/ob-python.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 69312f2c9..0e3c79522 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -335,7 +335,8 @@ last statement in BODY, as elisp."
 						  "python-")))
 			       (with-temp-file tmp-src-file (insert body))
 			       (format org-babel-python--exec-tmpfile
-				       tmp-src-file))
+				       (org-babel-process-file-name
+					tmp-src-file 'noquote)))
 			   body)))
 	       (mapconcat
 		#'org-trim
@@ -353,7 +354,8 @@ last statement in BODY, as elisp."
 					      "python-")))
 			   (with-temp-file tmp-src-file (insert body))
 			   (format org-babel-python--eval-ast
-				   tmp-src-file))))
+				   (org-babel-process-file-name
+				    tmp-src-file 'noquote)))))
                (org-babel-comint-with-output
                    (session org-babel-python-eoe-indicator nil body)
                  (let ((comint-process-echoes nil))
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-09-05 14:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17 18:47 [PATCH] ob-python.el: Fix issue with sessions on remote machines Christian Vanderwall
2020-08-18 14:21 ` Jack Kamm
2020-08-21  1:37   ` Jack Kamm
2020-09-04  9:55     ` Bastien
2020-09-05  1:08       ` Jack Kamm
2020-09-05  8:15         ` Bastien
2020-09-05 14:39           ` Jack Kamm
2020-09-05 14:48             ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).