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 passdevice_name="MYDEV". - TLS: pass your own
tls_context=(e.g. with a private CA loaded), ortls_verify=Falseto skip certificate checks (insecure; logs a warning).
Keys and errors
send_attn()andsend_sysreq()send Attn and System Request. They are not AID keys, sosend_key(AID.ATTN)/send_key(AID.SYSREQ)raiseValueError. SysReq needs a TN5250E session.- When the host shows an operator error on the status line (Write Error Code),
send_keyand everywait_for_*raiseOperatorError. The host text is inerr.message(it is kept out ofstr(err)). Callreset()— the Reset key — to clear it before sending another key. - Writing text longer than a field raises
FieldOverflow; nothing is written. type_intoreturnsTruewhen 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; passdevice_name="PYTERM01"to keep it. - TLS verifies certificates by default: pass
tls_verify=False(or atls_context) for hosts with self-signed certificates. timeoutis now only the wait deadline; the socket usessocket_timeout(default 30 s).poll_intervalis accepted but unused.send_keywaits for the keyboard to unlock instead of reading one record, and raisesScreenWaitTimeoutif it stays locked.- Over-long field text raises
FieldOverflowinstead of being truncated, and shorter text now replaces the whole previous field content. wait_for_textno longer prints the screen.
Contributing
-
Clone the repo and install dependencies with
uv:uv sync --locked
-
Make your changes under
src/ibm5250/. -
Lint and run the test suite before opening a PR:
uv run ruff check . uv run pytest
-
Branch off
developand open your pull request againstdevelop(notmain— 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
developand opening PRs intodevelop.developpublishes.devNreleases so changes can be tried out before they're promoted tomain. mainis production — merges there are published as real, patch-bumped releases on PyPI.- The version in
pyproject.tomlis a base version only and is never hand-bumped for a release;scripts/compute_version.pycomputes the actual published version from what's already on PyPI at build time. See.github/workflows/README.mdfor 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)
| 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)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| 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 logRelease 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 logSecurity 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.
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 logA 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.