Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: IBM/tnz
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.3.4
Choose a base ref
...
head repository: IBM/tnz
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
58 changes: 58 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '26 20 * * *'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# Command-line programs to run using the OS shell.
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
20 changes: 20 additions & 0 deletions .github/workflows/mkdocs-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: mkdocs-build
on:
push:
branches:
- main

jobs:
deploy-gh-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: 3.13

- run: pip install --disable-pip-version-check -r requirements.txt
- run: mkdocs gh-deploy --force
88 changes: 52 additions & 36 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,73 @@
name: CI/CD

on: push
on:
push:
branches: [ "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "main" ]

jobs:
CI:
build-wheel:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: 3.13

- run: pip install --disable-pip-version-check -r requirements.txt
- run: pycodestyle tnz/*.py
- run: python -m build --wheel --outdir dist/
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

- run: mkdocs build

test-wheel:
needs: build-wheel
strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8', '3.9' ]
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ]
include:
- os: ubuntu-latest
- python-version: '3.7'
os: ubuntu-22.04

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install wheel
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint
run: |
pycodestyle tnz/*.py
- name: Install tnz
run: |
pip install .
- name: Run tests
run: |
pytest
- run: pip install --disable-pip-version-check pytest -c requirements.txt
- uses: actions/download-artifact@v4
- run: pip install $(ls dist/*.whl)
- run: zti --version
- run: pytest

CD:
deploy-pypi:
if: startsWith(github.ref, 'refs/tags')
needs: CI
needs: build-wheel
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2

- name: Install dependencies
run: |
pip install wheel build twine
- name: Build dist
run: |
python -m build --wheel --outdir dist/
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.13

- name: Publish
- run: git fetch --tags
- run: pip install --disable-pip-version-check -r requirements.txt
- uses: actions/download-artifact@v4
- run: twine upload --non-interactive -u __token__ dist/*
env:
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload --non-interactive -u __token__ dist/*
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
bin/
*.pyc
dist
@@ -10,3 +11,12 @@ _version.py
# Vim files
*~
*.sw?

# virtual environment
.venv

# VScode editor configs
.vscode/

# specific environment variables, e.g. host, user, password
.env
42 changes: 25 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
[![CI Status](
https://github.com/IBM/tnz/workflows/CI/badge.svg
[![CI/CD Status](
https://github.com/IBM/tnz/actions/workflows/pipeline.yml/badge.svg
)](https://github.com/IBM/tnz/actions/workflows/pipeline.yml)
[![PyPi Status](
https://img.shields.io/pypi/v/tnz.svg
)](https://pypi.org/project/tnz)
[![PyPi Downloads](
https://img.shields.io/pypi/dm/tnz
)](https://pypi.org/project/tnz)
[![OpenSSF Best Practices](
https://bestpractices.coreinfrastructure.org/projects/6762/badge
)](https://bestpractices.coreinfrastructure.org/projects/6762)

# tnz

Use a standard terminal emulator as a 3270 terminal interface. Write
scripts to automate 3270 terminal interaction. This is both a 3270
terminal emulator and a Python libary. The zti module provides a 3270
terminal emulator and a Python library. The zti module provides a 3270
user interface through a Windows Command Prompt or a unix/ascii
terminal. The tnz module handles the interface to the 3270 data
stream. The ati module allows for easier 3270 terminal automation.
@@ -32,13 +35,12 @@ you also install the [ebcdic](https://pypi.org/project/ebcdic)
package from PyPI.
Use pip to install the latest tnz:
```console
pip install ebcdic tnz
pip3 install ebcdic tnz
```

## Usage
### Automation
See [examples](https://github.com/IBM/tnz/blob/main/examples/) to get started writing a script to automate
3270 interaction.
See [examples](examples/) to get started writing a script to automate 3270 interaction.

### Emulator
Run the installed zti (Z Terminal Interface) script to start the
@@ -52,24 +54,31 @@ you can run zti with `python -m tnz.zti` instead.

Starting `zti` takes you into the zti command line interface shell.
Key tab for command completion, up/down for command history.
![screenshot](https://github.com/IBM/tnz/blob/main/png/zti-prompt1.png?raw=true "shell")
![screenshot](docs/png/zti-prompt1.png "shell")

The `goto` command takes you to a full screen 3270 interface. When
space is available in the terminal screen/window, a status line is
provided as well as a session selector.
![screenshot](https://github.com/IBM/tnz/blob/main/png/zti-host1.png?raw=true "3270 full screen")

The basic syntax of `goto` is:

```
goto fully-qualified-host-name[:port]
```

![screenshot](docs/png/zti-host1.png "3270 full screen")

In Windows, the Lucida Console font works well with graphic character
APL symbols exploited by ISPF.
![screenshot](https://github.com/IBM/tnz/blob/main/png/zti-host2.png?raw=true "Screenshot with APL symbols")
![screenshot](docs/png/zti-host2.png "Screenshot with APL symbols")

Large and arbitrarily-sized screens are supported.
![screenshot](https://github.com/IBM/tnz/blob/main/png/zti-host3.png?raw=true "Screenshot with large size")
![screenshot](docs/png/zti-host3.png "Screenshot with large size")

Standard unix/ascii terminals are supported. In the screenshot below,
PuTTY is used as the terminal emulator. The connection was made from
PuTTY to z/OS via ssh and zti is running on z/OS.
![screenshot](https://github.com/IBM/tnz/blob/main/png/zti-host4.png?raw=true "Screenshot using PuTTY")
![screenshot](docs/png/zti-host4.png "Screenshot using PuTTY")

The code in this repository aims to be portable. To achieve this, the
number of dependencies is kept to a minimum. The only hard
@@ -100,10 +109,6 @@ select text. Once the text is selected, press Enter to copy the
text.** There are other ways to select text, but I this to be the
easiest.

Do NOT use Control-menu->Edit->Paste to paste text (unless the
text in the clipboard has ONLY printable characters - no line
breaks). Instead, **use Shift+Insert to paste**.

Before establishing a session, get the window sized the way you want
it. Window resizing is not handled well in Windows. If you _do_
resize, just use Esc to get to the command prompt then `goto` to get
@@ -116,10 +121,13 @@ fairly good at connecting like they are supposed to.


## Documentation
See docstrings in source code.

See [here](https://ibm.github.io/tnz/).

For additional details, see docstrings in source code.

## Contributing
See [CONTRIBUTING.md](https://github.com/IBM/tnz/blob/main/CONTRIBUTING.md).
See [CONTRIBUTING.md](CONTRIBUTING.md).

## Acknowledgments
Hats off to the team responsible for the IBM internal Automated Task
7 changes: 7 additions & 0 deletions docs/ati-compat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ati (compatability)
::: tnz.ati
options:
filters:
- "!^_"
- "!^Ati"
group_by_category: false
6 changes: 6 additions & 0 deletions docs/ati.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ati
::: tnz.ati
options:
members:
- "ati"
- "Ati"
11 changes: 11 additions & 0 deletions docs/colors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Colors
---

By default, *tnz* will emulate a 3270 terminal that has 8 colors and `zti` will assume a host terminal capable of true color is being used and use a *tnz\-defined color palette* to display those 8 terminal colors.

If you do not want (or cannot use, in the case of `Terminal.app`) this default color behavior, you can use the `TNZ_COLORS` environment variable. Use `export TNZ_COLORS=256` to direct `zti` to use the 256\-color palette instead of true color. Set to an integer less than 16 and `zti` will assume only the *standard* ansi colors can be used (for example `export TNZ_COLORS=8`). This can be helpful if your terminal doesn't support true color or if you want to change the colors to your liking \- terminal emulators typically allow you to set the ansi colors. Set to an integer less than 8 and tnz will emulate a 3270 terminal that has no color capability and `zti` will not use any color capability.

The following table describes, for each color mode, the host terminal colors used for the 8 different 3270 colors. If different colors are desired, check the zti\-hosting terminal for the capability to change the color palette. You may need to use TNZ\_COLORS=8 to get zti to use the customized color palette.

**The actual terminal 8\-bit color palette may not match the table above. It is common for terminal emulators to customize the palette.**
Loading