Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

python5250

ibm5250 is a pure-Python library for automating IBM 5250 terminal sessions against IBM i (AS/400) systems over TN5250/TN5250E. It speaks the Telnet negotiation, 5250 data stream, and screen/field model directly — no green-screen emulator or external dependencies required — so you can script sign-on, navigation, and data entry against a 5250 host from plain Python.

See src/ibm5250/data-stream-logic.md for a detailed walkthrough of how the library parses the wire protocol into screen state.

Installation

pip install ibm5250

Requires Python >= 3.11.

Usage

from ibm5250 import Terminal, AID

with Terminal("as400.example.com") as t:
    t.wait_for_text("Sign On")
    t.find_field_by_label("User").value = "MYUSER"
    t.find_field_by_label("Password").value = "SECRET"
    t.send_key(AID.ENTER)
    t.wait_for_text("Main Menu")
    print(t.screen.get_screen_text())

send_key blocks until the host has finished replying (the keyboard unlocks), however many records that takes.

Connection options

Terminal(
    "as400.example.com",
    port=992,
    use_tls=True,         # certificate and hostname are verified by default
    timeout=5.0,          # deadline for send_key / wait_for_* (seconds)
    socket_timeout=30.0,  # connect, negotiation and per-read socket limit
)
  • Device name: the host assigns one (e.g. QPADEV0008) unless you pass device_name="MYDEV".
  • TLS: pass your own tls_context= (e.g. with a private CA loaded), or tls_verify=False to skip certificate checks (insecure; logs a warning).

Keys and errors

  • send_attn() and send_sysreq() send Attn and System Request. They are not AID keys, so send_key(AID.ATTN) / send_key(AID.SYSREQ) raise ValueError. SysReq needs a TN5250E session.
  • When the host shows an operator error on the status line (Write Error Code), send_key and every wait_for_* raise OperatorError. The host text is in err.message (it is kept out of str(err)). Call reset() — the Reset key — to clear it before sending another key.
  • Writing text longer than a field raises FieldOverflow; nothing is written.
  • type_into returns True when filling an Auto-Enter field sent Enter.

Upgrading from 0.1.x

These changes can break existing code:

  • No default device name: it was PYTERM01; pass device_name="PYTERM01" to keep it.
  • TLS verifies certificates by default: pass tls_verify=False (or a tls_context) for hosts with self-signed certificates.
  • timeout is now only the wait deadline; the socket uses socket_timeout (default 30 s). poll_interval is accepted but unused.
  • send_key waits for the keyboard to unlock instead of reading one record, and raises ScreenWaitTimeout if it stays locked.
  • Over-long field text raises FieldOverflow instead of being truncated, and shorter text now replaces the whole previous field content.
  • wait_for_text no longer prints the screen.

Contributing

  1. Clone the repo and install dependencies with uv:

    uv sync --locked
    
  2. Make your changes under src/ibm5250/.

  3. Lint and run the test suite before opening a PR:

    uv run ruff check .
    uv run pytest
    
  4. Branch off develop and open your pull request against develop (not main — see Branching & releases below).

There's no separate contribution guide configured in this repo — just make sure ruff check and pytest both pass.

Branching & releases

Every push runs the test suite in CI. What gets built and published to PyPI depends on the branch:

Branch Tested Built Published to PyPI Version format
main ✅ ✅ ✅ production X.Y.Z (patch auto-incremented from the latest release)
develop ✅ ✅ ✅ development X.Y.Z.devN
any other branch ✅ ✅ ❌ (build artifact only) n/a
  • Contribute by branching off develop and opening PRs into develop. develop publishes .devN releases so changes can be tried out before they're promoted to main.
  • main is production — merges there are published as real, patch-bumped releases on PyPI.
  • The version in pyproject.toml is a base version only and is never hand-bumped for a release; scripts/compute_version.py computes the actual published version from what's already on PyPI at build time. See .github/workflows/README.md for the full CI/publishing setup.

License

Licensed under the Mozilla Public License 2.0.

Metadata

Release files for ibm5250 0.1.0.dev16

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ibm5250 0.1.0.dev16
File Size Uploaded Provenance Actions
ibm5250-0.1.0.dev16.tar.gz 69.8 kB With provenance Details for ibm5250-0.1.0.dev16.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ibm5250 0.1.0.dev16
File Interpreter ABI Platform Actions
ibm5250-0.1.0.dev16-py3-none-any.whl Python 3 none any Details for ibm5250-0.1.0.dev16-py3-none-any.whl

Total release size: 135.7 kB

Release files / ibm5250-0.1.0.dev16.tar.gz

Download URL ibm5250-0.1.0.dev16.tar.gz
Size 69.8 kB
Tags Source
SHA-256 checksum
How to use checksums
63c09c488c22f24e3c6f3f332b199366c77836c521700d20f4651f8200204d86
BLAKE2b-256 checksum
How to use checksums
b53f909bfa3761ae70b09181083b71b754996b09e57c6e97d31c3db8a0b1b24c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / ibm5250-0.1.0.dev16-py3-none-any.whl

Download URL ibm5250-0.1.0.dev16-py3-none-any.whl
Size 65.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f1bc4a4b3736a995e4be5971b0ac243929ca7504cda58a98def9c5475d11666b
BLAKE2b-256 checksum
How to use checksums
e9f7f5b1d856b02e7057b0d507a02630d0878944ce0ff4599423382a6aed47b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for ibm5250 0.1.0.dev16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ibm5250-0.1.0.dev16.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page