[chirp_devel] Issue with mem.immutable and exporting to CSV files
In a recently submitted bug report (Bug #9748) it was mentioned that upon attempting to export the tab the following error appears.
"There was an error during export: Field power is not mutable on this memory"
This appears to be related to this bit of code.
if mem.number <= 30 and self._gmrs: GMRS_IMMUTABLE = ["freq", "duplex", "offset"] if mem.number >= 8 and mem.number <= 14: mem.immutable = GMRS_IMMUTABLE + ["mode", "power"] else: mem.immutable = GMRS_IMMUTABLE
The error appears while CHIRP while building the data liste for the "Export to File" dialog. Once it gets to channel 8 (the first in a group of 7 channels which must remain set to Low power), the error is triggered.
Removing "power" from the GMRS_IMMUTABLE list eliminates the error.
What seems odd to me is that the transmit power level is not even saved to a CSV file so I don't understand why it would have anything to do with exporting data to a CSV file.
I would like to come up with a solution to this issue without removing "power" from the list.
Does anyone have any ideas?
Thanks, Jim KC9HI
The error appears while CHIRP while building the data liste for the "Export to File" dialog. Once it gets to channel 8 (the first in a group of 7 channels which must remain set to Low power), the error is triggered.
Removing "power" from the GMRS_IMMUTABLE list eliminates the error.
What seems odd to me is that the transmit power level is not even saved to a CSV file so I don't understand why it would have anything to do with exporting data to a CSV file.
I would like to come up with a solution to this issue without removing "power" from the list.
Does anyone have any ideas?
This is probably a bug in other drivers too. The import(/export) logic definitely predates the presence of the immutable list and seems obviously wrong for any memory with such a list. The logic does properly make a copy of the source memory before altering it to be appropriate for the destination, but doesn't remove the immutable list. Unless you're importing from or exporting to a radio of the same model, the immutable list per memory won't be the same. And, with some radios having immutable memories only in some locations, you could probably import/export the same model and the immutability wouldn't be right unless using one of those magic locations. Since immutable is really just "advice" to the UI to help the user know what they can and can't change, it doesn't help us during import and we should rely on set_memory() to not set anything that can't be adjusted.
So, tl;dr; I think this is the change you want, which fixes the case you're talking about, but also probably for any other potential case where the import logic needs to tweak an immutable field for whatever radio it's importing from or exporting to:
diff --git a/chirp/import_logic.py b/chirp/import_logic.py index c2ed867d..cc6a3662 100644 --- a/chirp/import_logic.py +++ b/chirp/import_logic.py @@ -203,6 +203,10 @@ def import_mem(dst_radio, src_features, src_mem, overrides={}): ensure_has_calls(dst_radio, src_mem)
dst_mem = src_mem.dupe() + # The source's immutable list almost definitely does not match the + # latter, so eliminate that list here and rely on set_memory() on + # the destination to enforce anything that should not be set. + dst_mem.immutable = []
for k, v in overrides.items(): dst_mem.__dict__[k] = v
Make sense?
--Dan
Dan and Chirp-Devel,
On Sun, Feb 13, 2022 at 1:32 PM Dan Smith via chirp_devel chirp_devel@intrepid.danplanet.com wrote:
So, tl;dr; I think this is the change you want, which fixes the case you're talking about, but also probably for any other potential case where the import logic needs to tweak an immutable field for whatever radio it's importing from or exporting to:
diff --git a/chirp/import_logic.py b/chirp/import_logic.py index c2ed867d..cc6a3662 100644 --- a/chirp/import_logic.py +++ b/chirp/import_logic.py @@ -203,6 +203,10 @@ def import_mem(dst_radio, src_features, src_mem, overrides={}): ensure_has_calls(dst_radio, src_mem)
dst_mem = src_mem.dupe()
# The source's immutable list almost definitely does not match the
# latter, so eliminate that list here and rely on set_memory() on
# the destination to enforce anything that should not be set.
dst_mem.immutable = []
for k, v in overrides.items(): dst_mem.__dict__[k] = v
Make sense?
Yes. I'll give it a shot.
Thanks, Jim KC9HI
participants (2)
-
Dan Smith
-
Jim Unroe