-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Of course. Here is a draft for a GitHub issue description based on the problem we solved.
Title: App crashes on non-Linux systems due to missing nmcli
Description
The application crashes on startup when run on operating systems other than Linux, such as macOS. This is because it tries to use the nmcli
command-line tool, which is not available on these platforms.
Error Log
Traceback (most recent call last):
File "/Users/gregkopp/Projects/rotary-controller-python/./rcp/main.py", line 23, in <module>
asyncio.run(MainApp().async_run())
...
File "/Users/gregkopp/Projects/rotary-controller-python/rcp/components/setup/network_screen.py", line 46, in __init__
self.wifi_enabled = nmcli.radio().wifi
...
FileNotFoundError: [Errno 2] No such file or directory: 'nmcli'
Cause
The network_screen.py file directly calls nmcli
functions to manage network state. If nmcli
is not in the system's PATH, a FileNotFoundError
is raised, which is unhandled and causes the application to terminate.
Proposed Fix
The fix is to make the application resilient to the absence of nmcli
. This can be achieved by:
- Wrapping
nmcli
calls intry...except FileNotFoundError
blocks. - In the
except
block, log a warning message indicating thatnmcli
was not found and that network features will be disabled. - Use a flag (e.g.,
self.wifi_enabled
) to track the availability ofnmcli
. - Conditionally disable UI elements and functionality that depend on
nmcli
based on this flag.
This ensures the application remains functional on non-Linux systems, with network management features gracefully disabled.