[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ssh-deploy 965c68f 028/173: Centralized asynchronous sh
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ssh-deploy 965c68f 028/173: Centralized asynchronous shell commands. |
Date: |
Sat, 20 Oct 2018 10:36:24 -0400 (EDT) |
branch: externals/ssh-deploy
commit 965c68fe6ae4eabab28faad37ce2a57e3e343b46
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Centralized asynchronous shell commands.
---
ssh-deploy.el | 51 +++++++++++++++------------------------------------
1 file changed, 15 insertions(+), 36 deletions(-)
diff --git a/ssh-deploy.el b/ssh-deploy.el
index 56ba163..71ac9fd 100644
--- a/ssh-deploy.el
+++ b/ssh-deploy.el
@@ -134,6 +134,17 @@
(and (not (null string))
(not (zerop (length string)))))
+(defun ssh-deploy-run-shell-command (command)
+ "Run COMMAND in asynchronous mode."
+ (message "Shell command: '%s'" command)
+ (let ((proc (start-process-shell-command "process" nil command)))
+ (set-process-filter proc (lambda (proc output)(message "%s"
(replace-regexp-in-string "\^M" "\n" output))))
+ (set-process-sentinel proc (lambda (proc output)
+ (if (string= (symbol-name (process-status
proc)) "exit")
+ (if (= (process-exit-status proc) 0)
+ (message "Successfully ran shell
command.")
+ (message "Failed to run shell
command.")))))))
+
(defun ssh-deploy (local-root remote-root upload-or-download path)
"Upload/Download relative to the roots LOCAL-ROOT with REMOTE-ROOT via SSH
according to UPLOAD-OR-DOWNLOAD and the path PATH."
(let ((file-or-directory (file-regular-p path)))
@@ -146,53 +157,21 @@
(if file-or-directory
(progn
(let ((command (concat "scp " (shell-quote-argument
path) " " (shell-quote-argument remote-path))))
- (message "Upload command: '%s'" command)
- (let ((proc (start-process-shell-command "process"
nil command)))
- (set-process-filter proc (lambda (proc
output)(message "%s" (replace-regexp-in-string "\^M" "\n" output))))
- (set-process-sentinel proc (lambda (proc output)
- (if (string=
(symbol-name (process-status proc)) "exit")
- (if (=
(process-exit-status proc) 0)
- (message
"Successfully uploaded file.")
- (message "Failed
to upload file."))))))))
+ (ssh-deploy-run-shell-command command)))
(progn
(let ((command (concat "scp -r " (shell-quote-argument
path) " " (shell-quote-argument (file-name-directory (directory-file-name
remote-path))))))
- (message "Upload command: '%s'" command)
- (let ((proc (start-process-shell-command "process" nil
command)))
- (set-process-filter proc (lambda (proc
output)(message "%s" (replace-regexp-in-string "\^M" "\n" output))))
- (set-process-sentinel proc (lambda (proc output)
- (if (string= (symbol-name
(process-status proc)) "exit")
- (if (=
(process-exit-status proc) 0)
- (message
"Successfully uploaded directory.")
- (message "Failed to
upload directory"))))))))))
+ (ssh-deploy-run-shell-command command)))))
(progn
(message "Downloading path '%s' to '%s'.." remote-path path)
(if file-or-directory
(progn
(message "Downloading file '%s' to '%s'.." remote-path
path)
(let ((command (concat "scp " (shell-quote-argument
remote-path) " " (shell-quote-argument path))))
- (message "Download command: '%s'" command)
- (let ((proc (start-process-shell-command "process" nil
command)))
- (set-process-filter proc (lambda (proc
output)(message "%s" (replace-regexp-in-string "\^M" "\n" output))))
- (set-process-sentinel proc (lambda (proc output)
- (if (string= (symbol-name
(process-status proc)) "exit")
- (if (=
(process-exit-status proc) 0)
- (progn
- (message
"Successfully downloaded file.")
- (revert-buffer))
- (message "Failed to
download file."))))))))
+ (ssh-deploy-run-shell-command command)))
(progn
(message "Downloading directory '%s' to '%s'.."
remote-path path)
(let ((command (concat "scp -r " (shell-quote-argument
remote-path) " " (shell-quote-argument (file-name-directory
(directory-file-name path))))))
- (message "Download command: '%s'" command)
- (let ((proc (start-process-shell-command "process" nil
command)))
- (set-process-filter proc (lambda (proc output)(message
"%s" (replace-regexp-in-string "\^M" "\n" output))))
- (set-process-sentinel proc (lambda (proc output)
- (if (string= (symbol-name
(process-status proc)) "exit")
- (if (=
(process-exit-status proc) 0)
- (progn
- (message
"Successfully downloaded directory.")
- (revert-buffer))
- (message "Failed to
download directory."))))))))))))
+ (ssh-deploy-run-shell-command command)))))))
(if ssh-deploy-debug
(message "Path '%s' is not in the root '%s'" path local-root))))))
- [elpa] externals/ssh-deploy 8faa3c1 018/173: Now checks in path is in local-root before browsing remote host., (continued)
- [elpa] externals/ssh-deploy 8faa3c1 018/173: Now checks in path is in local-root before browsing remote host., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 3bbbbfb 017/173: *** empty log message ***, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy f77eba5 012/173: Updated README with proper setup example and instructions about MELPA., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 5ad07f2 008/173: Changed requirements., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 1ebf003 010/173: Formatted text a bit better., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy ebdbb7e 014/173: Add TRAMP protocol for difference queries, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy fa368fb 020/173: Made relative path generation as stand-alone function and now checks if ztree and tramp-term is installed before trying to call them., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy f4ad77d 026/173: Now works asynchrously, moved (revert-buffer) to successful downloads instead of to key-binding., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 05ed4c8 009/173: Made changes to comply with MELPA guidelines., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 89fb82a 038/173: Fixed bug when downloading via SSH to a local path containing whitespaces, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 965c68f 028/173: Centralized asynchronous shell commands.,
Stefan Monnier <=
- [elpa] externals/ssh-deploy e6e1ad8 039/173: Updated version and modified date, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 2257f95 029/173: Fixed upload and downloads of root directories where local root directory name differs from remote root directory name., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 560ff1d 037/173: Added TRAMP functions and improved messages., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy a86091c 032/173: Broken down diff function into multiple functions to easily add new protocols., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 1e58dc3 040/173: SSH deployment now works via TRAMP instead of SCP, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 4a2f947 053/173: Fixed bug where missing remote file used wrong logic, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 61a16be 047/173: Merged remote, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy d599659 015/173: Added support for opening remote terminals, uploads/downloads/differences of directories, browsing remote hosts and fixed a bug where paths with special chars were not handled correctly., Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 1af0208 045/173: Cleaned up code structure and isolated functions, Stefan Monnier, 2018/10/20
- [elpa] externals/ssh-deploy 740c27d 054/173: Fixed message when no base revision exists and remote file equals local file, Stefan Monnier, 2018/10/20