Skip to content

Support Moxa NPort firmware 2.x backups and update copier template to 5.1.0 - #58

Merged
LeeHudsonDLS merged 8 commits into
mainfrom
tserv_fw2_fix
Jun 30, 2026
Merged

Support Moxa NPort firmware 2.x backups and update copier template to 5.1.0#58
LeeHudsonDLS merged 8 commits into
mainfrom
tserv_fw2_fix

Conversation

@LeeHudsonDLS

@LeeHudsonDLS LeeHudsonDLS commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary:
Enables backing up Moxa NPort firmware 2.x terminal servers, including HTTPS-only devices and ones reachable only via a SOCKS proxy (e.g. the vacuum-control terminal servers on the isolated CIA network). Also updates the copier template to 5.1.0 and restores the runtime dependencies the migration had dropped.

HTTPS handling:

  • Adds Moxa NPort firmware 2.x support (HTTPS with self-signed cert, SHA256-challenge login, BackupRestore.htm export flow).
  • The server field may now carry a scheme, e.g. "https://host:8026", to reach HTTPS-only devices directly (such as one behind a port forward exposing only port 443). With no scheme, the old behaviour is kept (default http://, follow the firmware redirect). Scheme is stripped from the backup filename.

SOCKS proxy:

  • Adds the requests[socks] extra so backups can run through a SOCKS proxy via the standard HTTPS_PROXY/HTTP_PROXY env vars (no code change). Used with ssh -D 1080 @login.pri and socks5h://localhost:1080 (remote DNS), letting the backup run from outside the isolated CIA network.

Build / dependencies:

  • Updates copier 3.1.0 > 5.1.0 (uv-based workflows, renovate, .python-version, refreshed devcontainer/Dockerfile).
  • Restores runtime deps and regenerates uv.lock; adds epicscorelibs (bundles libca).
  • Caps Python to >=3.11,<3.13 (telnetlib, removed in 3.13, is required by dls-pmaclib); fixes the main:main entry point.

Testing:

  • Verified against live VA terminal servers through the SOCKS tunnel (uv run dls-backup-bl --domain VA, single-cell -d srNNc), backing up firmware 2.x devices over HTTPS.

LeeHudsonDLS and others added 3 commits June 12, 2026 11:38
- handle https redirect with self-signed certificate on moxa backup
- support new SHA256 challenge login alongside the old MD5 scheme
- skip the firmware 2.x login history page and fetch the export
  csrf_token from BackupRestore.htm when ConfExp.htm is gone
- raise an error if the export returns the login page (bad credentials)
- tolerate urllib3 >= 2.0 which removed DEFAULT_CIPHERS
- stage deleted files with git CLI add as IndexFile.add cannot
Apply the python-copier-template 5.1.0 update: switch to uv-based CI/
release/container workflows, replace dependabot with renovate, drop the
install_requirements action and the _pypi workflow, and add
.python-version and .gitleaks.toml. Also refreshes the devcontainer,
pre-commit, Dockerfile, README and CONTRIBUTING to match the template.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The 3.1.0->5.1.0 template migration reset project.dependencies to an
empty list and rerouted the console script through __main__, leaving the
tool unable to run. Restore the dependencies and fix the fallout:

- pyproject: re-add runtime deps (dls-pmacanalyse, dls-pmaclib, cothread,
  epicscorelibs, gitpython, attrs, pexpect, requests[socks], pyqt5) and
  regenerate uv.lock
- pyproject/ci: cap python to >=3.11,<3.13 because brick.py and
  dls-pmaclib import the stdlib telnetlib removed in 3.13; drop the
  3.13/3.14 classifiers and CI matrix entries
- __main__: expose backup.main as `main` so the dls-backup-bl entry point
  resolves
- tserver: let a moxa "server" carry an https:// scheme for https-only
  devices (e.g. via a port forward), wrap two over-length log messages,
  and strip the scheme from the backup filename

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 15.55556% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.35%. Comparing base (bc197a4) to head (38477cc).

Files with missing lines Patch % Lines
src/dls_backup_bl/tserver.py 11.90% 37 Missing ⚠️
src/dls_backup_bl/repository.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #58      +/-   ##
==========================================
- Coverage   29.73%   29.35%   -0.39%     
==========================================
  Files          10       10              
  Lines         797      821      +24     
==========================================
+ Hits          237      241       +4     
- Misses        560      580      +20     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

LeeHudsonDLS and others added 3 commits June 24, 2026 11:39
GitPython, imported by repository.py, requires the git executable on
PATH at import time. The minimal ubuntu:noble runtime stage didn't
include it, so `docker run ... --version` failed with "Bad git
executable". Install git in the runtime image.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This is a hardware-facing repo where much of the code talks to live
devices over the network, so automated coverage is limited by design.
Report coverage without failing pull requests on it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@LeeHudsonDLS

Copy link
Copy Markdown
Collaborator Author

Hold fire on the merge, I seem to have put in a wrong answer when running copier update that prevents the PyPi publishing. Fixing now

@LeeHudsonDLS

Copy link
Copy Markdown
Collaborator Author

OK ready to merge and release

@JamesOHeaDLS JamesOHeaDLS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Lee, looks good

@LeeHudsonDLS
LeeHudsonDLS merged commit 82777a1 into main Jun 30, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants