A Python interface for Attachmate Extra! X-treme
Project description
py-troya-connect
'py-troya-connect' is a Python framework for interacting with Attachmate Extra! X-treme based Troya terminal sessions.
Installation
pip install py-troya-connect
Quick Start
from py_troya_connect import ExtraTerminal
# Interactive session selection
session = ExtraTerminal.select_session()
terminal = ExtraTerminal(session)
terminal.connect()
# Basic screen operations
screen_content = terminal.read_screen()
print(screen_content)
terminal.disconnect()
Key Features
Session Management
# List all available sessions
terminal = ExtraTerminal("1")
sessions = terminal.list_available_sessions()
for session in sessions:
print(f"Session {session['index']}: {session['name']} - {'Connected' if session['connected'] else 'Disconnected'}")
# Interactive session selection
session = ExtraTerminal.select_session()
terminal = ExtraTerminal(session)
Terminal Operations
with ExtraTerminal("1") as terminal:
# Send command with automatic formatting
terminal.send_command("CLEAR") # Automatically adds <ENTER>
# Send complex commands with special keys
terminal.send_command("USER123{TAB}PASS456{ENTER}")
# Read screen content
screen = terminal.read_screen(strip_whitespace=True)
print(screen)
# Wait for specific text to appear
if terminal.wait_for_text("READY", timeout=30):
terminal.send_command("NEXT_COMMAND")
Output Management
from py_troya_connect import ExtraTerminal
# Basic connection
terminal = ExtraTerminal("1") # Connect to first session
terminal.connect()
# Send a command and read response
terminal.send_command("A10JANISTESB")
# First option : Bulk output
screen = terminal.read_screen(strip_whitespace=True)
print(screen)
# Second option : Stripped by row output
screen = terminal.read_screen(strip_whitespace=False)
print(screen)
'strip_whitespace (bool): If True, returns list of stripped lines. If False, returns raw screen content. Defaults to True.'
Error Handling
from py_troya_connect import ExtraTerminalError, ConnectionError, SessionError
try:
terminal = ExtraTerminal("1")
terminal.connect()
except ConnectionError as e:
print(f"Connection failed: {e.message}")
print(f"Error code: {e.error_code}")
print(f"Details: {e.details}")
except SessionError as e:
print(f"Session error: {e.message}")
System Diagnostics
# Check terminal status
terminal = ExtraTerminal("1")
status = terminal.check_system_status()
print(f"Extra Version: {status['Extra Version']}")
print(f"Total Sessions: {status['Session Count']}")
print(f"Available Sessions: {', '.join(status['Available Sessions'])}")
Interactive Usage
# Built-in interactive mode
if __name__ == "__main__":
session = ExtraTerminal.select_session()
with ExtraTerminal(session) as terminal:
while True:
command = input("Enter command (or 'exit'): ")
if command.lower() == 'exit':
break
terminal.send_command(command)
print(terminal.read_screen())
Requirements
- Windows OS
- Attachmate Extra! X-treme terminal
- Python 3.6+
- pywin32
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py_troya_connect-0.1.3152.tar.gz
(10.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_troya_connect-0.1.3152.tar.gz.
File metadata
- Download URL: py_troya_connect-0.1.3152.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9d8854f8ec965fc40d1680a917b9677b5319ca8e2097fec2d955d8ed01b40e9
|
|
| MD5 |
0c68036f90037c49c115cb575c0dbc29
|
|
| BLAKE2b-256 |
7f214b76022ce6937954e23396d8ec47dacecdb8e9bf5dffbff30ecdf46c3ccd
|
File details
Details for the file py_troya_connect-0.1.3152-py3-none-any.whl.
File metadata
- Download URL: py_troya_connect-0.1.3152-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86372025680a0988048dd14554d10d866aa16f200ffb2c480f2cb5778c9184dc
|
|
| MD5 |
7f047cc31f1611fa631bea6e5a4cbb64
|
|
| BLAKE2b-256 |
df18bbd863e59232216adcf2a63529107c175e25f649ea33e6c031d6912537d1
|