import os

from ..Playbooks.Playbook import FileCleanupTask, PlaybookCredentialCollection
from ...Logging.Logger import log, Severity
from ..SetupStep import SetupStep

class CheckForSSHSession(SetupStep):
    def __init__(self):
        super().__init__()

    def run(self, file_cleanup_stack : list[FileCleanupTask], credentials: PlaybookCredentialCollection) -> bool:
        if 'SSH_CONNECTION' in os.environ or 'SSH_CLIENT' in os.environ:
            log("SSH connection detected.", Severity.WARN)
            return False
        else:
            log("No SSH connection detected.", Severity.DEBUG)
            return True