hifiberry / hifiberry-dsp

DSP toolkit
MIT License
138 stars 36 forks source link

mergeparameters AttributeError: 'dict' object has no attribute 'move_to_end' #53

Closed corrpel closed 1 year ago

corrpel commented 1 year ago

Hello, I am trying to use the merge tool for metadata, but i receive the following errors:

''' pi@raspberrypi:~/phat $ mergeparameters dsc_phat.xml dsc_phat.params Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/hifiberrydsp/parser/xmlprofile.py", line 253, in update_metadata beometa = self.doc["ROM"]["beometa"] KeyError: 'beometa'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/bin/mergeparameters", line 28, in merge_params_main() File "/usr/local/lib/python3.9/dist-packages/hifiberrydsp/parser/sigmaparams.py", line 236, in merge_params_main params = pf.merge_params_into_xml(xmlfile) File "/usr/local/lib/python3.9/dist-packages/hifiberrydsp/parser/sigmaparams.py", line 190, in merge_params_into_xml xml.update_metadata(param_list) File "/usr/local/lib/python3.9/dist-packages/hifiberrydsp/parser/xmlprofile.py", line 257, in update_metadata self.doc["ROM"].move_to_end('beometa', last=False) AttributeError: 'dict' object has no attribute 'move_to_end' '''

Running python3.9 and and latest dsptoolkit from pip

KruzFX commented 1 year ago

I just experienced the same problem. Two years ago when I last used the tool there was no such a problem. Maybe there is a problem with new python versions?

ssalonen commented 1 year ago

Just hit this issue myself, it is due to backwards compatible change in xmltodict v0.13 (xmltodict is dsptoolkit dependency)

Fix is simple: xmltodict.parse() needs additional parameter dict_constructor=OrderedDict. In parser/xmlprofile.py:

self.doc = xmltodict.parse(fd.read(), dict_constructor=OrderedDict)
KruzFX commented 1 year ago

Thanks for the reply. But where is the file when installed on my Raspberry Pi?

ssalonen commented 1 year ago

You can see it in the error message

Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/hifiberrydsp/parser/xmlprofile.py"

ssalonen commented 1 year ago

PR submitted in https://github.com/hifiberry/hifiberry-dsp/pull/54