diff options
Diffstat (limited to 'examples/python/dbus/is-wwan-default.py')
| -rwxr-xr-x | examples/python/dbus/is-wwan-default.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/python/dbus/is-wwan-default.py b/examples/python/dbus/is-wwan-default.py index d6e2b12e..38dc1735 100755 --- a/examples/python/dbus/is-wwan-default.py +++ b/examples/python/dbus/is-wwan-default.py @@ -30,8 +30,9 @@ proxy = bus.get_object(NM_SERVICE_NAME, "/org/freedesktop/NetworkManager") manager = dbus.Interface(proxy, NM_MANAGER_IFACE) props = dbus.Interface(proxy, DBUS_PROPS_IFACE) + def found_connection_type(ctype): - if ctype == '': + if ctype == "": print("No active connection") elif ctype in ["gsm", "cdma", "bluetooth"]: print("WWAN is default") @@ -39,6 +40,7 @@ def found_connection_type(ctype): print("WWAN is not default") sys.exit(0) + # Shortcut #1, for NM 1.0 try: ctype = props.Get(NM_MANAGER_IFACE, "PrimaryConnectionType") @@ -50,7 +52,7 @@ except KeyError: try: primary = props.Get(NM_MANAGER_IFACE, "PrimaryConnection") if not primary: - found_connection_type('') + found_connection_type("") primary_proxy = bus.get_object(NM_SERVICE_NAME, primary) primary_props = dbus.Interface(primary_proxy, DBUS_PROPS_IFACE) ctype = primary_props.Get(NM_ACTIVE_CONNECTION_INTERFACE, "Type") @@ -83,4 +85,3 @@ if default_is_wwan: print("WWAN is default") else: print("WWAN is not default") - |