# HG changeset patch # User Ludovic Chabant # Date 1506740359 25200 # Node ID 5713b6a2850d6da01c8720b904668dfc9ae3f724 # Parent b447c24bc8d4a97d2a62b4ce30ae27565563cc74 chef: Optimize startup time a little bit. diff -r b447c24bc8d4 -r 5713b6a2850d piecrust/publishing/sftp.py --- a/piecrust/publishing/sftp.py Fri Sep 29 17:05:09 2017 -0700 +++ b/piecrust/publishing/sftp.py Fri Sep 29 19:59:19 2017 -0700 @@ -1,9 +1,6 @@ import os import os.path -import urllib.parse -import getpass import logging -import paramiko from piecrust.publishing.base import Publisher, PublisherConfigurationError @@ -30,6 +27,8 @@ raise PublisherConfigurationError( "Publish target '%s' doesn't specify a 'host'." % self.target) + + import urllib.parse remote = urllib.parse.urlparse(host) hostname = remote.hostname @@ -45,6 +44,7 @@ password = None if username and not ctx.preview: + import getpass password = getpass.getpass("Password for '%s': " % username) if ctx.preview: @@ -52,6 +52,8 @@ self._previewUpload(ctx, path) return + import paramiko + logger.debug("Connecting to %s:%s..." % (hostname, port)) lfk = (not username and not pkey_path) sshc = paramiko.SSHClient()