Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix obvious errors when NetworkManager is missing #547

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion eduvpn/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ def update_state_callback(callback):
# This exits the main loop and gives back control to the CLI
callback()

nm.action_with_mainloop(update_state_callback)
if self.nm_manager.available:
nm.action_with_mainloop(update_state_callback)

def interactive(self, _):
# Show a title and the help
Expand Down
10 changes: 4 additions & 6 deletions eduvpn/nm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@
from eduvpn.utils import run_in_glib_thread
from eduvpn.variants import ApplicationVariant

gi.require_version("NM", "1.0") # noqa: E402
from gi.repository import GLib # type: ignore
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably something like gi.require_version("GLib", "2.0") or such should also be inserted here...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever works is fine by me :)

from gi.repository.Gio import Task # type: ignore

_logger = logging.getLogger(__name__)

LINUX_NET_FOLDER = Path("/sys/class/net")

try:
import gi

gi.require_version("NM", "1.0")
from gi.repository import NM, GLib # type: ignore
from gi.repository import NM # type: ignore
except (ImportError, ValueError):
_logger.warning("Network Manager not available")
NM = None
Expand Down Expand Up @@ -238,7 +236,7 @@ def iface(self) -> Optional[str]:
return devices[0].get_iface()

@property
def ipv4_config(self) -> Optional[NM.IPConfig]:
def ipv4_config(self) -> Optional["NM.IPConfig"]:
"""
Get the ipv4 config for the active VPN connection
"""
Expand Down Expand Up @@ -792,7 +790,7 @@ def quit_loop(*args, **kwargs):


def add_connection_callback(
client: NM.Client, result: Task, user_data: Tuple[NMManager, Optional[Callable]]
client: "NM.Client", result: Task, user_data: Tuple[NMManager, Optional[Callable]]
) -> None:
object, callback = user_data
new_con = client.add_connection_finish(result)
Expand Down
1 change: 0 additions & 1 deletion eduvpn/ui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import gi

gi.require_version("Gtk", "3.0") # noqa: E402
gi.require_version("NM", "1.0") # noqa: E402
from datetime import datetime
from functools import partial

Expand Down
Loading