Skip to content

App crashes on non-Linux systems due to missing nmcli #32

Description

@gregkopp

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:

  1. Wrapping nmcli calls in try...except FileNotFoundError blocks.
  2. In the except block, log a warning message indicating that nmcli was not found and that network features will be disabled.
  3. Use a flag (e.g., self.wifi_enabled) to track the availability of nmcli.
  4. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions