pyocd / pyocd-pemicro

PEMicro probe plugin for pyOCD
Other
3 stars 1 forks source link

AttributeError: 'PEMicroException' object has no attribute 'message' #2

Closed anthrax-0 closed 3 years ago

anthrax-0 commented 3 years ago

As pypemicro package has removed the message field in the latest version 0.1.6, the current version of pyocd-pemicro can't catch specific exceptions and being now installed by default it always fails pyocd on the system without libraries @flit :

:#sudo pyocd list
0001632:CRITICAL:__main__:uncaught exception: 'PEMicroException' object has no attribute 'message'
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pypemicro/pemicro.py", line 403, in get_pemicro_lib
    filename = PyPemicro.get_newest_lib_filename(libs_list)
  File "/usr/local/lib/python3.7/dist-packages/pypemicro/pemicro.py", line 381, in get_newest_lib_filename
    raise PEMicroException("Unable to find any usable library in the system!")
pypemicro.pemicro.PEMicroException: Unable to find any usable library in the system!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pypemicro/pemicro.py", line 419, in list_ports
    lib = PyPemicro.get_pemicro_lib()
  File "/usr/local/lib/python3.7/dist-packages/pypemicro/pemicro.py", line 407, in get_pemicro_lib
    raise PEMicroException(str(exc))
pypemicro.pemicro.PEMicroException: Unable to find any usable library in the system!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pyocd_pemicro/pemicro_probe.py", line 82, in get_all_connected_probes
    port_list = pemicro.list_ports()
  File "/usr/local/lib/python3.7/dist-packages/pypemicro/pemicro.py", line 421, in list_ports
    raise PEMicroException(str(exc))
pypemicro.pemicro.PEMicroException: Unable to find any usable library in the system!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pyocd/__main__.py", line 401, in run
    self._COMMANDS[self._args.cmd](self)
  File "/usr/local/lib/python3.7/dist-packages/pyocd/__main__.py", line 461, in do_list
    ConnectHelper.list_connected_probes()
  File "/usr/local/lib/python3.7/dist-packages/pyocd/core/helpers.py", line 109, in list_connected_probes
    allProbes = ConnectHelper.get_all_connected_probes(blocking=False)
  File "/usr/local/lib/python3.7/dist-packages/pyocd/core/helpers.py", line 82, in get_all_connected_probes
    allProbes = DebugProbeAggregator.get_all_connected_probes(unique_id=unique_id)
  File "/usr/local/lib/python3.7/dist-packages/pyocd/probe/aggregator.py", line 64, in get_all_connected_probes
    probes += cls.get_all_connected_probes(unique_id, is_explicit)
  File "/usr/local/lib/python3.7/dist-packages/pyocd_pemicro/pemicro_probe.py", line 89, in get_all_connected_probes
    if cls.NO_LIBRARY_ERR in exc.message:
AttributeError: 'PEMicroException' object has no attribute 'message' 

All two instances of if cls.NO_LIBRARY_ERR not in exc.message: has to be replaced. For example, if cls.NO_LIBRARY_ERR not in str(exc): seems to work.

anthrax-0 commented 3 years ago

Sorry for the comments spamming. It seems https://github.com/pyocd/pyocd-pemicro/blob/main/pyocd_pemicro/pemicro_probe.py#L107 should actually be if cls.NO_LIBRARY_ERR in str(exc):

flit commented 3 years ago

Thanks for the report! I'll pin the version of pypemicro so this can't happen again.

cederom commented 3 years ago

I have also encountered this problem, reported here https://github.com/pyocd/pyOCD/pull/1154. Will try the pyocd-pemicro master and report back :-)

Update: I can confirm this is fixed in the master. I now have problem with OS detection, will report in a separate issue :-)