fossasia / fossasia/pslab-python
Clarify CLI runtime behavior when migrating away from deprecated pslab.serial_handler
- Langage dominant
- Python
- Étoiles
- 1.6k
- Forks
- 242
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
### Background
The `pslab.serial_handler` module is deprecated and emits warnings during build and runtime.
A newer API is available via `pslab.connection.SerialHandler`.
Migrating to the new API is necessary, but the two implementations differ in runtime behavior, particularly regarding connection states.
### Current CLI behavior
In `pslab/cli.py`, the CLI currently:
- Instantiates `SerialHandler(port=args.port)`
- Uses the handler immediately without explicitly calling `connect()`
- Relies on the deprecated module's **implicit** connection behavior to function.
### Behavior difference with `pslab.connection`
The newer `pslab.connection.SerialHandler`:
- Does **not** auto-connect on initialization.
- Requires an explicit `.connect()` call to open the port.
- Will fail at runtime if used immediately after instantiation without connection.
### Proposed Resolution
To safely migrate to the new API, the CLI logic in `pslab/cli.py` will be updated to:
1. **Explicit Connection:** Call `handler.connect()` immediately after instantiation.
2. **Lifecycle Management:** Wrap the execution in a `try...finally` block to ensure `handler.disconnect()` is called on exit.
3. **Port Handling:** Ensure `args.port` is passed correctly to support both specific port selection and auto-discovery.
### Related work
- PR: #267 (Implementation in progress)
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez dans pslab/cli.py et comparez le cycle de vie de son handler avec pslab.connection.SerialHandler. Vérifiez que la CLI se connecte explicitement, transmette args.port dans les cas de port sélectionné et de découverte automatique, et se déconnecte à la sortie ; le PR associé #267 indique que l’implémentation est déjà en cours.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- cli
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 25/100