# Path: statik/deploy/base.py
# class DeploymentMethod(object):
#     """An abstract method for handling deployment."""
# 
#     def __init__(self, config, error_context=None):
#         """Must validate the given configuration for this deployment method and raise an exception
#         if it's invalid."""
#         raise NotImplementedError
# 
#     def execute(self, source_path):
#         """Must actually execute the implemented deployment method."""
#         raise NotImplementedError
# 
# Path: statik/errors.py
# class ProjectConfigurationError(StatikError):
#     """For generic project configuration-related errors."""
#     error_kind = "Project configuration error"
#     exit_code = 2
# 
# class DeploymentError(StatikError):
#     """For errors relating to deployment of built projects."""
#     error_kind = "Deployment-related error"
#     exit_code = 9


import os
import os.path
import getpass
import paramiko
import logging
from .base import DeploymentMethod
from ..errors import ProjectConfigurationError, DeploymentError
            logger.debug(
                "Both private key and password are present - favouring "
                "password-based authentication (do not specify a password if you "
                "want to rather use private key-based authentication)"
            )
            self.private_key = None

    def execute(self, source_path):
        copy_via_sftp(
            source_path,
            self.dest_path,
            host=self.host,
            port=self.port,
            user=self.user,
            password=self.password,
            pkey=self.private_key,
        )


def copy_via_sftp(source_path, dest_path, host=None, port=None, user=None,
        password=None, pkey=None, rm_dest=False):
    with paramiko.transport.Transport((host, port)) as transport:
        logger.info("Connecting to %s:%d" % (host, port))
        try:
            transport.connect(
                username=user,
                password=password,
                pkey=pkey,
            )
        except paramiko.SSHException as e:

# Path: statik/deploy/base.py
# class DeploymentMethod(object):
#     """An abstract method for handling deployment."""
# 
#     def __init__(self, config, error_context=None):
#         """Must validate the given configuration for this deployment method and raise an exception
#         if it's invalid."""
#         raise NotImplementedError
# 
#     def execute(self, source_path):
#         """Must actually execute the implemented deployment method."""
#         raise NotImplementedError
# 
# Path: statik/errors.py
# class ProjectConfigurationError(StatikError):
#     """For generic project configuration-related errors."""
#     error_kind = "Project configuration error"
#     exit_code = 2
# 
# class DeploymentError(StatikError):
#     """For errors relating to deployment of built projects."""
#     error_kind = "Deployment-related error"
#     exit_code = 9


# Path: statik/deploy/sftp.py
import os
import os.path
import getpass
import paramiko
import logging
from .base import DeploymentMethod
from ..errors import ProjectConfigurationError, DeploymentError

            logger.debug(
                "Both private key and password are present - favouring "
                "password-based authentication (do not specify a password if you "
                "want to rather use private key-based authentication)"
            )
            self.private_key = None

    def execute(self, source_path):
        copy_via_sftp(
            source_path,
            self.dest_path,
            host=self.host,
            port=self.port,
            user=self.user,
            password=self.password,
            pkey=self.private_key,
        )


def copy_via_sftp(source_path, dest_path, host=None, port=None, user=None,
        password=None, pkey=None, rm_dest=False):
    with paramiko.transport.Transport((host, port)) as transport:
        logger.info("Connecting to %s:%d" % (host, port))
        try:
            transport.connect(
                username=user,
                password=password,
                pkey=pkey,
            )
        except paramiko.SSHException as e:

            raise DeploymentError("Failed to connect to %s:%d: %s" %