MyTooliT / ICOc

ICOc is a tool to control the ICOtronic system, acquire data, and test stationary transceiver units and sensory tool holders.
https://mytoolit.github.io/ICOc/
2 stars 0 forks source link

ICOn Rename: Handle Timeout #59

Closed sanssecours closed 3 months ago

sanssecours commented 4 months ago

Description

The command icon rename does not exit cleanly, if you try to rename a sensor device which is not available.

Steps to Reproduce

Try to rename a sensor device that is not available

icon rename -d 1000 Test-STH

Expected Result

The tool exits showing an error message, e.g. something like

TimeoutError: Unable to find sensor device with device_number “1000” in 20 seconds

Found the following sensor devices:
🤖 Name: CGvXAd6B, Device Number: 0, MAC address: 08-6B-D7-01-DE-81, RSSI: -39

Actual Result

The command prints a stack trace:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\Rene\AppData\Local\Programs\Python\Python312\Scripts\icon.exe\__main__.py", line 7, in <module>
  File "C:\Users\Rene\Documents\Projects\ICOc\mytoolit\scripts\icon.py", line 376, in main
    run(command_to_coroutine[arguments.subcommand](arguments))
  File "C:\Users\Rene\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Rene\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Rene\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Rene\Documents\Projects\ICOc\mytoolit\scripts\icon.py", line 294, in rename
    await network.connect_sensor_device(identifier)
  File "C:\Users\Rene\Documents\Projects\ICOc\mytoolit\can\network.py", line 1819, in connect_sensor_device
    raise TimeoutError(
TimeoutError: Unable to find sensor device with device_number “1000” in 20 seconds

Found the following sensor devices:
🤖 Name: CGvXAd6B, Device Number: 0, MAC address: 08-6B-D7-01-DE-81, RSSI: -39