diff piecrust/publishing/sftp.py @ 923:5713b6a2850d

chef: Optimize startup time a little bit.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 29 Sep 2017 19:59:19 -0700
parents 13e8b50a2113
children
line wrap: on
line diff
--- 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()