Skip to content

Feat/pbscontrol#77

Draft
lcaflc wants to merge 2 commits intomainfrom
feat/pbscontrol
Draft

Feat/pbscontrol#77
lcaflc wants to merge 2 commits intomainfrom
feat/pbscontrol

Conversation

@lcaflc
Copy link
Copy Markdown
Contributor

@lcaflc lcaflc commented Apr 7, 2026

Add a new tool into the project. This tool will mimic pvecontrol but for Proxmox Backup Server.

Still things to discuss about:

  • new tool integration into the project
  • configuration file:
    • completely separate configuration file in a new config path: ~/.config/pbscontrol/config.yaml
    • separate configuration file in the same config folder: ~/.config/pvecontrol/pbscontrol.yaml and rename / add compat for pvecontrol.yaml
    • same configuration file with a dedicated section.

lcaflc added 2 commits April 7, 2026 18:07
Only the simple tool and a status command as a proof of concept
@plaffitt
Copy link
Copy Markdown
Collaborator

A few suggestions from Claude. I removed some of its comments and annotated some other. It points out some interesting facts, maybe some of them worth considering:

Code quality & conventions

Significant duplication with pvecontrol

  • get_leaf_command, IgnoreRequiredForHelp, the signal handler, urllib3 warning disable, logging setup and CLI group scaffolding are copy-pasted from src/pvecontrol/__init__.py. These will drift. Consider extracting a shared internal module (eg. pvecontrol.cli or a new common package) used by both entry points.
  • set_config in src/pbscontrol/config.py uses the same serverconfig = False anti-pattern as pvecontrol/config.py line 57. Prefer None. (NOTE: idk what he means by "anti-pattern here", probably worth to check)

PBSServer.__init__ side effects (src/pbscontrol/models/server.py:14-21)

  • Hitting the network inside __init__ (_initstatus) makes the class hard to test without mocks and couples construction with I/O. Consider a .connect() or lazy properties.
  • except SSLError: print(e); sys.exit(1) mixes library code with process exit and prints to stdout. Raise and let the CLI layer handle exit; log via logging.error to stderr.

Inconsistent error handling

Unused/minor issues

  • src/tests/pbscontrol/fixtures/api.py:2 imports requests but never uses it.
  • src/pbscontrol/__init__.py:14 imports OutputFormats but never uses it in this file (used in actions/server.py).
  • __main__.py calls pbscontrol.main() without sys.exit(...), while __init__.py line 157 wraps in sys.exit(main()). Harmonize.
  • percent computation duplicated between the text and table branches in actions/server.py; factor out.
  • test_server.py:44 has a local import inside the test body; move to module top.
  • The many print(...) debug statements in fixtures/api.py will pollute test output. Prefer logging.debug or remove.

Tests

  • No test for the status CLI command itself (only for get_leaf_command and the model). Add at least one invocation-level test via Click's CliRunner.
  • No test for auth handling via create_from_config (the config + run_auth_commands path is untested here).

Design questions (matches PR description)

  • Package is published under name pvecontrol (setup.cfg:2) but ships two console scripts. Fine, but a short note in README on how to install and invoke pbscontrol would help.

Suggested changes before merge

  1. Remove unused imports, the stray prints in fixtures, and the inner local import in tests.
  2. Extract the CLI scaffolding shared with pvecontrol into a common module, even if minimal.
  3. Stop calling sys.exit(1) / print(e) from inside PBSServer.__init__; let the CLI layer handle it.
  4. Add at least one CliRunner-based test for pbscontrol status.

Nothing blocks the direction; it's a clean first cut. The big call is the config layout, which you've already flagged.

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