File: testing.py

package info (click to toggle)
python-spur 0.3.23-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 216 kB
  • sloc: python: 1,188; makefile: 39
file content (25 lines) | stat: -rw-r--r-- 624 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os

import spur
import spur.ssh


def _int_or_none(val):
    return int(val) if val is not None else None


HOSTNAME = os.environ.get("TEST_SSH_HOSTNAME", "127.0.0.1")
USERNAME = os.environ["TEST_SSH_USERNAME"]
PASSWORD = os.environ["TEST_SSH_PASSWORD"]
PORT = _int_or_none(os.environ.get("TEST_SSH_PORT", 22))


def create_ssh_shell(missing_host_key=None, shell_type=None):
    return spur.SshShell(
        hostname=HOSTNAME,
        username=USERNAME,
        password=PASSWORD,
        port=PORT,
        missing_host_key=(missing_host_key or spur.ssh.MissingHostKey.accept),
        shell_type=shell_type,
    )