Skip to content

Commit f41fe75

Browse files
authored
Merge pull request #1 from Luminger/modernize
Release v0.2.0 - Major Modernization and Feature Expansion
2 parents 4834524 + 39d24f0 commit f41fe75

33 files changed

Lines changed: 3804 additions & 645 deletions

.flake8

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/actions/build/action.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build distribution
2+
description: Builds the distribution
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Disable initramfs update
8+
shell: bash
9+
run: sudo sed -i 's/yes/no/g' /etc/initramfs-tools/update-initramfs.conf
10+
11+
- name: Disable man-db update
12+
shell: bash
13+
run: sudo rm -f /var/lib/man-db/auto-update
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.x"
19+
20+
- name: Install uv
21+
shell: bash
22+
run: python3 -m pip install uv
23+
24+
- name: Build distribution packages
25+
shell: bash
26+
run: uv build
27+
env:
28+
UV_PROJECT_ENVIRONMENT: .venv
29+
30+
- name: Store distribution packages
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: python-package-distributions
34+
path: dist/

.github/actions/check/action.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Run linter and tests
2+
description: Runs the format check, linter, type check and tests
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Disable initramfs update
8+
shell: bash
9+
run: sudo sed -i 's/yes/no/g' /etc/initramfs-tools/update-initramfs.conf
10+
11+
- name: Disable man-db update
12+
shell: bash
13+
run: sudo rm -f /var/lib/man-db/auto-update
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.x"
19+
20+
- name: Install uv
21+
shell: bash
22+
run: python3 -m pip install uv
23+
24+
- name: Setup project
25+
shell: bash
26+
run: uv sync --group dev
27+
env:
28+
UV_PROJECT_ENVIRONMENT: .venv
29+
30+
- name: Run ruff check
31+
uses: astral-sh/ruff-action@v3
32+
with:
33+
args: "check"
34+
35+
- name: Run ruff format check
36+
uses: astral-sh/ruff-action@v3
37+
with:
38+
args: "format --check"
39+
40+
- name: Run tests
41+
shell: bash
42+
run: uv run pytest tests/ --replay -v
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check and Build
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
check:
8+
name: Check
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Check
16+
uses: ./.github/actions/check
17+
18+
build:
19+
name: Build
20+
runs-on: ubuntu-latest
21+
needs: [check]
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Build
28+
uses: ./.github/actions/build

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Continuous Integration
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
check-and-build:
9+
uses: ./.github/workflows/check-and-build.yml

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __pycache__/
99
# Distribution / packaging
1010
.Python
1111
build/
12+
!.github/actions/build/
1213
develop-eggs/
1314
dist/
1415
downloads/
@@ -127,3 +128,13 @@ dmypy.json
127128

128129
# Pyre type checker
129130
.pyre/
131+
132+
# Devenv
133+
.devenv*
134+
devenv.local.nix
135+
136+
# direnv
137+
.direnv
138+
139+
# pre-commit
140+
.pre-commit-config.yaml

.vscode/settings.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
2-
"python.analysis.typeCheckingMode": "basic",
3-
"python.linting.flake8Enabled": true,
4-
"python.linting.mypyEnabled": true,
5-
"python.linting.mypyCategorySeverity.note": "Warning",
6-
"[python]": {
7-
"editor.formatOnSave": true,
8-
"editor.defaultFormatter": "ms-python.black-formatter"
9-
},
10-
}
2+
"python.analysis.typeCheckingMode": "strict",
3+
"[python]": {
4+
"editor.formatOnSave": true,
5+
"editor.defaultFormatter": "charliermarsh.ruff"
6+
}
7+
}
8+

CHANGELOG.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.2.0] - 2025-10-17
9+
10+
### Added
11+
12+
- **High-level KVM interface**: New `KVM` class in `kvm.py` providing type-safe, structured interface for library usage
13+
- **Multi-device addressing**: Support for controlling multiple KVM switches on the same serial bus (addresses 0-99)
14+
- **Device discovery**: New `discover` command to find all devices on the serial bus with their firmware versions
15+
- **Comprehensive CLI commands** (replacing simple console.py):
16+
- `status`: Show system status with firmware version and address
17+
- `help`: Display device help information
18+
- `input switch`: Switch inputs with output selection
19+
- `output routing`: Query current input-to-output routing
20+
- `output stream`: Check output stream status
21+
- `edid get/set`: Manage EDID data for inputs
22+
- `discover`: Find all devices on the serial bus
23+
- Multiple output formats: `--format raw|json|pretty`
24+
- **Comprehensive test suite**: Full test coverage with pytest
25+
- Unit tests for `Device`, `KVM`, and CLI commands
26+
- Integration tests for end-to-end workflows
27+
- Hardware replay tests using pytest-reserial (no hardware needed for CI)
28+
- Test coverage reporting with pytest-cov
29+
- **Test scripts** for different testing scenarios:
30+
- `test-record.sh`: Record serial traffic from real hardware
31+
- `test-replay.sh`: Run tests using recorded traffic (CI-friendly)
32+
- `test-with-hardware.sh`: Run tests with actual hardware
33+
- **Enhanced documentation**:
34+
- Extensive README with installation, usage examples, and library usage guide
35+
- Development setup instructions with uv
36+
- Testing documentation
37+
- **Product documentation**: Added official EZCOO KVM switch manual (PDF) in `docs/`
38+
- **CI/CD workflows**: GitHub Actions for automated testing and building on pull requests
39+
- Composite actions for check and build steps
40+
- Reusable workflow for check-and-build
41+
- CI workflow triggered on PRs to main
42+
- **Release documentation**: Complete manual release process guide in `RELEASING.md` including:
43+
- Version bumping and changelog updates
44+
- GitHub release creation
45+
- PyPI publishing
46+
- AUR package updates
47+
48+
### Changed
49+
50+
- **BREAKING**: License changed from Apache-2.0 to GPL-3.0-or-later
51+
- **BREAKING**: Migrated from Poetry to uv for dependency management
52+
- Removed `poetry.lock` and `poetry.toml`
53+
- Added `uv.lock` and updated `pyproject.toml` to use PEP 621 format
54+
- Changed build backend from poetry-core to hatchling
55+
- **BREAKING**: Migrated from flake8 to ruff for linting and formatting
56+
- Removed flake8, flake8-black, flake8-import-order
57+
- Added ruff with comprehensive rule configuration
58+
- Removed `.flake8` configuration file
59+
- **BREAKING**: Complete CLI rewrite (`cli.py` replaces `console.py`)
60+
- New command structure with subcommands and groups
61+
- Added `--address` option for multi-device support
62+
- Added `--format` option for output formatting (raw/json/pretty)
63+
- Default output format changed from raw device response to human-readable pretty format
64+
- Removed direct device command exposure
65+
- All commands now use high-level KVM interface
66+
- **BREAKING**: Enhanced `Device` class with improved error handling
67+
- Added `DeviceError` and `DeviceConnectionError` exceptions
68+
- Added command validation to prevent injection attacks
69+
- Better error messages for connection and communication failures
70+
- Configurable baudrate and timeout parameters
71+
- Type hints updated to use modern Python 3.10+ syntax (`Self`, `type[]`)
72+
- **BREAKING**: Response parsing now returns structured `KVMResponse[T]` objects
73+
- Generic type parameter ensures type safety
74+
- Includes raw command, raw response lines, and parsed response
75+
- Enables both programmatic access and raw output
76+
- **Type safety improvements**:
77+
- Added `StreamState` enum for on/off states
78+
- Generic `KVMResponse[T]` wrapper for all responses
79+
- Proper type hints throughout codebase
80+
- Dataclasses for all structured data
81+
- **Dependencies**:
82+
- Removed: `attrs`, `mypy`, `flake8` family
83+
- Added: `pytest`, `pytest-cov`, `pytest-reserial`, `ruff`
84+
- Updated: `click` to 8.1.3+, `pyserial` to 3.5+
85+
- Minimum Python version: 3.10
86+
87+
### Removed
88+
89+
- **console.py**: Replaced by comprehensive `cli.py` with structured commands
90+
- **Poetry configuration**: Migrated to uv
91+
- **flake8 configuration**: Migrated to ruff
92+
- **attrs dependency**: Replaced with standard library dataclasses
93+
94+
### Fixed
95+
96+
- Improved error handling in device communication with specific exception types
97+
- Better validation of command responses with structured parsing
98+
- More reliable serial port handling with proper connection error handling
99+
- Command injection prevention through input validation
100+
101+
### Development
102+
103+
- Added `.vscode/settings.json` with Python and testing configurations
104+
- Updated `.gitignore` with uv-specific patterns and test artifacts
105+
- Enhanced `pyproject.toml` with:
106+
- Ruff configuration (line length, linting rules)
107+
- Pytest configuration (test paths, coverage options)
108+
- Coverage configuration (source paths, exclusions)
109+
- Dependency groups for dev dependencies
110+
111+
## [0.1.1] - 2024-XX-XX
112+
113+
### Changed
114+
115+
- Bump dependencies
116+
117+
## [0.1.0] - 2024-XX-XX
118+
119+
### Fixed
120+
121+
- Fix wrong baudrate
122+
123+
### Changed
124+
125+
- Move things around and refactoring
126+
127+
## [0.0.1] - 2024-XX-XX
128+
129+
### Added
130+
131+
- Initial PoC implementation
132+
133+
[0.2.0]: https://github.com/Luminger/ezcoo-cli/compare/0.1.1...0.2.0
134+
[0.1.1]: https://github.com/Luminger/ezcoo-cli/compare/0.1.0...0.1.1
135+
[0.1.0]: https://github.com/Luminger/ezcoo-cli/compare/0.0.1...0.1.0
136+
[0.0.1]: https://github.com/Luminger/ezcoo-cli/releases/tag/0.0.1

0 commit comments

Comments
 (0)