carj / pyPreservica

Python language binding for the Preservica API
https://pypreservica.readthedocs.io
Apache License 2.0
14 stars 2 forks source link

Entity API | entity_events -> KeyError: 'commandType' #8

Closed redbeks closed 2 years ago

redbeks commented 2 years ago

Hi James,

When requesting the events for a specific entity with the entity_events method in the EntityAPI, it seems that some attributes like 'commandType' are not always available (maybe in the case of a deleted entity), resulting to a KeyError:

File "venv\lib\site-packages\pyPreservica\entityAPI.py", line 1866, in entity_events paged_set = self._entity_events_page(entity) File "venv\lib\site-packages\pyPreservica\entityAPI.py", line 1820, in _entity_events_page result = {'commandType': event_action.attrib['commandType']} KeyError: 'commandType'

carj commented 2 years ago

Hi I have made a change to check for the key before accessing the element. Can you upgrade to the latest version and re-try

https://pypi.org/project/pyPreservica/1.5.3/

redbeks commented 2 years ago

Thank you so much for your quick answer,

Everything is working fine now !