add support for .cfg export/import#944
Conversation
adds binary import and export to mirror functionality of android (and soon ios) app
|
Caution Review failedFailed to post review comments. GitHub was unavailable or timed out while CodeRabbit was posting the review. Please request a new review later if the pull request still needs one. This happened while posting 3 inline comments. Use ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🧰 Additional context used🪛 ast-grep (0.44.0)meshtastic/__main__.py[warning] 754-754: File path is request-/variable-derived; validate and normalize to prevent path traversal. (open-filename-from-request) [warning] 766-766: File path is request-/variable-derived; validate and normalize to prevent path traversal. (open-filename-from-request) [warning] 837-837: File path is request-/variable-derived; validate and normalize to prevent path traversal. (open-filename-from-request) [warning] 964-964: File path is request-/variable-derived; validate and normalize to prevent path traversal. (open-filename-from-request) [warning] 977-977: File path is request-/variable-derived; validate and normalize to prevent path traversal. (open-filename-from-request) 🪛 Ruff (0.15.20)meshtastic/__main__.py[warning] 761-761: Do not catch blind exception: (BLE001) [warning] 968-968: Do not catch blind exception: (BLE001) [warning] 981-981: Do not catch blind exception: (BLE001) 📝 WalkthroughWalkthroughAdds binary protobuf ( Config Import/Export
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment Warning |
Description
This PR adds support for exporting and importing binary device profiles (
.cfg), bringing the Python CLI to feature parity with the Android app's configuration backup functionality.Key Changes
DeviceProfileprotobuf message. This captures all the same settings as the existing yaml import/export.--import-configas a clear alias for the existing--configurecommand.--export-format(acceptsauto,yaml,binary, orprotobuf) to explicitly override format detection during both imports and exports (binary, andprotobufboth do the same thing).--export-configdefaults toautoand generates a binary protobuf if the target file extension ends in.cfg. Otherwise, it falls back to the existing YAML behavior.--configureand--import-configrely on file contents rather than extensions. It attempts to parse the file as a YAML dictionary; if it fails (e.g., throwing a decode error on binary data), it assumes the file is a binaryDeviceProfileprotobuf and parses it accordingly.Summary by CodeRabbit
New Features
Bug Fixes