Skip to main content

A Selenium-inspired Python framework for terminal and SSH automation

Project description

Termitty 🐜

A powerful, Selenium-inspired Python framework for terminal and SSH automation.

Python Version License: MIT Code style: black

What is Termitty?

Termitty brings the elegance and simplicity of Selenium WebDriver to the world of terminal automation. Just as Selenium revolutionized web browser automation, Termitty transforms how developers interact with command-line interfaces programmatically.

🆚 Quick Comparison

Feature Termitty Fabric Paramiko Pexpect Ansible
Selenium-like API
Terminal Emulation ✅ Full ⚠️ Basic
Session Recording
AI-Ready
Interactive Shell ⚠️ ⚠️

→ See detailed comparison for more information

✨ Key Features

🎯 Intuitive Selenium-like API

# Familiar patterns for developers who've used Selenium
session = TermittySession()
session.connect('server.com', username='user', key_file='~/.ssh/id_rsa')
session.wait_until(OutputContains('Ready'))

🖥️ Advanced Terminal Emulation

  • Full ANSI escape code support
  • Virtual terminal with screen buffer management
  • Real-time terminal state tracking
  • Menu and UI element detection

⏱️ Smart Waiting & Pattern Matching

# Wait for specific conditions
session.wait_until(OutputContains('Task completed'), timeout=30)
session.wait_until(PromptReady('$ '))
session.wait_until(OutputMatches(r'Status: \d+%'))

🔄 Interactive Shell Sessions

# Handle interactive applications with ease
with session.interactive_shell() as shell:
    shell.send_line('vim config.txt')
    shell.wait_for_text('INSERT')
    shell.send_keys('Hello World')
    shell.send_key(Keys.ESCAPE)
    shell.send_line(':wq')

📹 Session Recording & Playback

# Record your terminal sessions
session.start_recording('demo.json')
# ... perform actions ...
recording = session.stop_recording()

# Playback later
player = Player('demo.json')
player.play(speed=2.0)

Parallel Execution

# Execute commands across multiple servers
hosts = ['server1.com', 'server2.com', 'server3.com']
pool = ConnectionPool(hosts, username='user', key_file='~/.ssh/id_rsa')

results = pool.execute_on_all('apt update && apt upgrade -y', 
                              strategy='rolling',
                              batch_size=2)

🎨 Terminal UI Navigation

# Navigate terminal UIs programmatically
menu_items = session.terminal.find_menu_items()
session.terminal.click_menu_item('Settings')

📦 Installation

pip install termitty

🚀 Quick Start

Basic Command Execution

from termitty import TermittySession

# Connect to a server
session = TermittySession()
session.connect('example.com', username='user', password='pass')

# Execute commands
result = session.execute('ls -la')
print(result.output)

# Use context managers for directory changes
with session.cd('/var/log'):
    logs = session.execute('tail -n 20 syslog')
    print(logs.output)

Interactive Application Handling

# Handle password prompts
session.execute('sudo apt update')
session.wait_until(OutputContains('[sudo] password'))
session.send_line('password', secure=True)

# Navigate interactive installers
session.execute('./install.sh')
session.wait_until(OutputContains('Do you accept? [y/N]'))
session.send_line('y')

Terminal Emulation

# Access the virtual terminal
terminal = session.terminal

# Get screen content
screen_text = terminal.get_screen_text()
print(screen_text)

# Find text on screen
if terminal.find_text('Error'):
    print("Error found at:", terminal.cursor_position)

# Take snapshots
snapshot = terminal.snapshot()

📚 Documentation

For comprehensive documentation, visit our docs folder or check out these guides:

🏗️ Architecture

Termitty is built with a modular architecture:

  • Session Layer: High-level API for SSH connections and command execution
  • Terminal Emulator: Full VT100/ANSI terminal emulation
  • Interactive Shell: Real-time interaction with persistent shell sessions
  • Recording System: Capture and replay terminal sessions
  • Parallel Executor: Efficient multi-host command execution

See our Architecture Documentation for detailed information.

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

Termitty is licensed under the MIT License. See LICENSE for details.

🛣️ Roadmap

  • Async/await support for all operations
  • File transfer capabilities (SCP/SFTP)
  • Built-in task templates for common operations
  • Terminal session sharing and collaboration
  • Web-based session viewer
  • Plugin system for custom extensions

💡 Use Cases

  • DevOps Automation: Automate server provisioning and configuration
  • Testing: Create robust tests for CLI applications
  • Monitoring: Build intelligent monitoring scripts that react to terminal output
  • Documentation: Record terminal sessions for tutorials and documentation
  • Deployment: Orchestrate complex multi-server deployments
  • AI Agents: Enable LLMs and coding assistants to control terminals → Learn more

🙏 Acknowledgments

This project is inspired by the elegance of Selenium WebDriver and the need for better terminal automation tools in the DevOps/SRE space.


Ready to automate your terminal workflows? Check out our examples to get started!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

termitty-0.1.0.tar.gz (66.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

termitty-0.1.0-py3-none-any.whl (74.6 kB view details)

Uploaded Python 3

File details

Details for the file termitty-0.1.0.tar.gz.

File metadata

  • Download URL: termitty-0.1.0.tar.gz
  • Upload date:
  • Size: 66.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for termitty-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7de91fd8772f88465d0bafd5594b67d6c43edf244297e9d8e054d8ae9270d6a4
MD5 c5e15d977fdebd95d37e72ea8fea4368
BLAKE2b-256 481cef7ea2869f43aa8a87f4dd25af24cf966af2aec67b3b8d05f7af2924406b

See more details on using hashes here.

File details

Details for the file termitty-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: termitty-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 74.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.9

File hashes

Hashes for termitty-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d497bb511905985af4a2e31186106bd6a5d6361d9475602ca018e0432e3fb40
MD5 a0e2cf719439484895bedc10ed6992d1
BLAKE2b-256 1ac09e4e622694e25efab717bad8533ddf75a7b2d4c6b8c047617953614ec069

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page