changeset 767:3b33d9fb007c

publish: Add support for `--preview` for the SFTP publisher.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 02 Jul 2016 01:27:56 -0700
parents f69fdc601845
children c78743b11c75
files piecrust/publishing/sftp.py
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/publishing/sftp.py	Sat Jul 02 01:27:00 2016 -0700
+++ b/piecrust/publishing/sftp.py	Sat Jul 02 01:27:56 2016 -0700
@@ -51,9 +51,14 @@
             pkey_path = self.getConfigValue('key')
 
         password = None
-        if username:
+        if username and not ctx.preview:
             password = getpass.getpass("Password for '%s': " % username)
 
+        if ctx.preview:
+            logger.info("Would connect to %s:%s..." % (hostname, port))
+            self._previewUpload(ctx, path)
+            return
+
         logger.debug("Connecting to %s:%s..." % (hostname, port))
         lfk = (not username and not pkey_path)
         sshc = paramiko.SSHClient()
@@ -75,6 +80,12 @@
         finally:
             sshc.close()
 
+    def _previewUpload(self, ctx, dest_dir):
+        if not ctx.args.force:
+            logger.info("Would upload new/changed files...")
+        else:
+            logger.info("Would upload entire website...")
+
     def _upload(self, session, client, ctx, dest_dir):
         if dest_dir:
             if dest_dir.startswith('~/'):