import logging import ntpath import sys import paramiko from tools.config import CONFIG from tools.persistence import KVStore _name = "sftp" # TODO: encryption kvstore = KVStore(_name) # Load SFTP server info from config file HOSTNAME = CONFIG.get(_name, "hostname") PORT = CONFIG.getint(_name, "port") USERNAME = CONFIG.get(_name, "username") AUTHENTICATION_TYPE = CONFIG.get(_name, "authentication_type") SFTP_BASE_DIR = CONFIG.get(_name, "base_dir") # The provided user for SFTP upload must have read and write permissions in the SFTP_BASE_DIR # (The SFTP_BASE_DIR has to exist, the user doesn't need permissions in the parent directory). # A lack of permissions in SFTP_BASE_DIR will break the SFTP upload functionality. def upload(file: str): # Upload preparations transport, sftp_client = _connect() try: sftp_client.chdir(SFTP_BASE_DIR)