# 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
ENVVAR_SFTP_KEY_FILE = "SFTP_KEY_FILE"
ENVVAR_SFTP_KEY_FILE_PASSWORD = "SFTP_KEY_FILE_PASSWORD"
DEFAULT_SFTP_PORT = 22
DEFAULT_SFTP_KEY_FILE = "~/.ssh/id_rsa"


class SFTP(DeploymentMethod):

    def __init__(self, config, error_context=None):
        self.host = os.environ.get(ENVVAR_SFTP_HOST, config.get('host', None))
        if self.host is None:
            raise ProjectConfigurationError(
                message="Missing host parameter for SFTP deployment",
                context=error_context,
            )

        self.port = int(
            os.environ.get(ENVVAR_SFTP_PORT, config.get('port', DEFAULT_SFTP_PORT))
        )
        self.dest_path = os.environ.get(
            ENVVAR_SFTP_DEST_PATH,
            config.get('dest-path', None),
        )
        if self.dest_path is None:
            raise ProjectConfigurationError(
                message="Missing destination path parameter for SFTP deployment",
                context=error_context,
            )
        self.user = os.environ.get(ENVVAR_SFTP_USER, config.get('user', None))
        if self.user is None:

# 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

ENVVAR_SFTP_KEY_FILE = "SFTP_KEY_FILE"
ENVVAR_SFTP_KEY_FILE_PASSWORD = "SFTP_KEY_FILE_PASSWORD"
DEFAULT_SFTP_PORT = 22
DEFAULT_SFTP_KEY_FILE = "~/.ssh/id_rsa"


class SFTP(DeploymentMethod):

    def __init__(self, config, error_context=None):
        self.host = os.environ.get(ENVVAR_SFTP_HOST, config.get('host', None))
        if self.host is None:
            raise ProjectConfigurationError(
                message="Missing host parameter for SFTP deployment",
                context=error_context,
            )

        self.port = int(
            os.environ.get(ENVVAR_SFTP_PORT, config.get('port', DEFAULT_SFTP_PORT))
        )
        self.dest_path = os.environ.get(
            ENVVAR_SFTP_DEST_PATH,
            config.get('dest-path', None),
        )
        if self.dest_path is None:
            raise ProjectConfigurationError(
                message="Missing destination path parameter for SFTP deployment",
                context=error_context,
            )
        self.user = os.environ.get(ENVVAR_SFTP_USER, config.get('user', None))
        if self.user is None:

            raise ProjectConfigurationError(