# HG changeset patch # User Ludovic Chabant # Date 1467448076 25200 # Node ID 3b33d9fb007c6ec5c98cf36ce6cfe186822a18f7 # Parent f69fdc601845f977a91f26b7ccb1a41094860ce2 publish: Add support for `--preview` for the SFTP publisher. diff -r f69fdc601845 -r 3b33d9fb007c piecrust/publishing/sftp.py --- 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('~/'):