From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id YBGWL8Joc1/wMwAA0tVLHw (envelope-from ) for ; Tue, 29 Sep 2020 17:02:58 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id +HNUK8Joc1+UUwAAbx9fmQ (envelope-from ) for ; Tue, 29 Sep 2020 17:02:58 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3DAA59402A0 for ; Tue, 29 Sep 2020 17:02:58 +0000 (UTC) Received: from localhost ([::1]:44092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kNJ1k-000816-7v for larch@yhetil.org; Tue, 29 Sep 2020 13:02:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kNJ07-0007ww-Fa for emacs-orgmode@gnu.org; Tue, 29 Sep 2020 13:01:15 -0400 Received: from pie.tf ([62.75.142.128]:53802) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kNIzy-0000Vm-My for emacs-orgmode@gnu.org; Tue, 29 Sep 2020 13:01:11 -0400 Received: from leintor.e.ffh.zone ([81.3.6.94] helo=localhost) by pie.tf with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.86_2) (envelope-from ) id 1kNIzr-0007Y6-3G; Tue, 29 Sep 2020 17:00:59 +0000 From: Ferdinand Pieper To: emacs-orgmode@gnu.org Subject: [PATCH] ob-gnuplot: handle remote input files Date: Tue, 29 Sep 2020 19:00:58 +0200 Message-ID: <87imbwsek5.fsf@ims.uni-hannover.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=62.75.142.128; envelope-from=fer@pie.tf; helo=pie.tf X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/29 13:01:00 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: 14 X-Spam_score: 1.4 X-Spam_bar: + X-Spam_report: (1.4 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: 3.29 X-TUID: aiGuak/0vGAT --=-=-= Content-Type: text/plain When passing a remote file like "/ssh:myserver:/myfile.txt" to a gnuplot block as variable the gnuplot process can not access the remote data. An example: --8<---------------cut here---------------start------------->8--- #+begin_src gnuplot :var data="/ssh:myserver:/myfile.txt" plot data u 1:2 #+end_src --8<---------------cut here---------------end--------------->8--- Attached is a patch, which instead downloads remote files to a unique path and passes this new path to gnuplot. Please let me know if there's something to improve regarding the commit message or patch formatting. Best, --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-ob-gnuplot-Download-remote-input-files.patch >From 4f9f98ed8f48754eeff09b8de51734bc8521bb6a Mon Sep 17 00:00:00 2001 From: fpi Date: Tue, 29 Sep 2020 18:43:07 +0200 Subject: [PATCH] ob-gnuplot: Download remote input files * lisp/ob-gnuplot.el (org-babel-gnuplot-process-vars): When variables point to remote files download them and use a local copy instead. --- lisp/ob-gnuplot.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lisp/ob-gnuplot.el b/lisp/ob-gnuplot.el index 62ab04d94..820929c84 100644 --- a/lisp/ob-gnuplot.el +++ b/lisp/ob-gnuplot.el @@ -92,7 +92,21 @@ code." (tablep (or (listp first) (symbolp first)))) (if tablep val (mapcar 'list val))) (org-babel-temp-file "gnuplot-") params) - val)))) + (if (and (file-remote-p val) ;; check if val is a remote file + (file-exists-p val)) ;; call to file-exists-p is slow, maybe remove it + (let* ((local-name (concat ;; create a unique filename to avoid multiple downloads + org-babel-temporary-directory + "/gnuplot/" + (file-remote-p val 'host) + (file-local-name val)))) + (if (and (file-exists-p local-name) ;; only download file if remote is newer + (file-newer-than-file-p local-name val)) + local-name + (make-directory (file-name-directory local-name) t) + (copy-file val local-name t) + )) + val + ))))) (org-babel--get-vars params)))) (defun org-babel-expand-body:gnuplot (body params) -- 2.20.1 --=-=-=--