diff options
| author | Dan Winship <danw@gnome.org> | 2014-05-19 13:44:02 -0400 |
|---|---|---|
| committer | Dan Winship <danw@gnome.org> | 2014-08-01 14:34:05 -0400 |
| commit | a7c4d53d036c0f75b0903c95de7cb8fbdc47413f (patch) | |
| tree | 861f6f385edb63a97b405b0593193db382d35aad /examples/python/gi | |
| parent | c5daa4c4df07d413e5f760eac5a2f686f6062225 (diff) | |
| download | NetworkManager-a7c4d53d036c0f75b0903c95de7cb8fbdc47413f.tar.gz | |
all: port everything to libnm
Since the API has not changed at this point, this is mostly just a
matter of updating Makefiles, and changing references to the library
name in comments.
NetworkManager cannot link to libnm due to the duplicated type/symbol
names. So it links to libnm-core.la directly, which means that
NetworkManager gets a separate copy of that code from libnm.so.
Everything else links to libnm.
Diffstat (limited to 'examples/python/gi')
| -rwxr-xr-x | examples/python/gi/add_connection.py | 32 | ||||
| -rwxr-xr-x | examples/python/gi/device-state-ip4config.py | 4 | ||||
| -rwxr-xr-x | examples/python/gi/firewall-zone.py | 6 | ||||
| -rwxr-xr-x | examples/python/gi/get-active-connections.py | 4 | ||||
| -rwxr-xr-x | examples/python/gi/get_ips.py | 4 | ||||
| -rwxr-xr-x | examples/python/gi/list-connections.py | 8 | ||||
| -rwxr-xr-x | examples/python/gi/show-wifi-networks.py | 10 | ||||
| -rwxr-xr-x | examples/python/gi/update-ip4-method.py | 12 |
8 files changed, 39 insertions, 41 deletions
diff --git a/examples/python/gi/add_connection.py b/examples/python/gi/add_connection.py index 76c2e94e62..86a34a1cbe 100755 --- a/examples/python/gi/add_connection.py +++ b/examples/python/gi/add_connection.py @@ -20,16 +20,14 @@ # # This example shows how to add a new NM connection profile. -# The code uses libnm-util (NetworkManager) and libnm-glib (NMClient) -# via GObject Introspection. +# The code uses libnm (NM) via GObject Introspection. # # Documentation links: -# https://developer.gnome.org/libnm-glib/0.9/ -# https://developer.gnome.org/libnm-util/0.9/ -# https://developer.gnome.org/NetworkManager/0.9/ref-settings.html +# https://developer.gnome.org/libnm/1.0/ +# https://developer.gnome.org/NetworkManager/1.0/ref-settings.html # -from gi.repository import GLib, NetworkManager, NMClient +from gi.repository import GLib, NM import sys, uuid main_loop = None @@ -39,19 +37,19 @@ def print_values(setting, key, value, flags, data): # create an Ethernet connection and return it def create_profile(name): - profile = NetworkManager.Connection.new() - s_con = NetworkManager.SettingConnection.new() - s_con.set_property(NetworkManager.SETTING_CONNECTION_ID, name) - s_con.set_property(NetworkManager.SETTING_CONNECTION_UUID, str(uuid.uuid4())) - s_con.set_property(NetworkManager.SETTING_CONNECTION_TYPE, "802-3-ethernet") + profile = NM.Connection.new() + s_con = NM.SettingConnection.new() + s_con.set_property(NM.SETTING_CONNECTION_ID, name) + s_con.set_property(NM.SETTING_CONNECTION_UUID, str(uuid.uuid4())) + s_con.set_property(NM.SETTING_CONNECTION_TYPE, "802-3-ethernet") - s_wired = NetworkManager.SettingWired.new() + s_wired = NM.SettingWired.new() - s_ip4 = NetworkManager.SettingIP4Config.new() - s_ip4.set_property(NetworkManager.SETTING_IP4_CONFIG_METHOD, "auto") + s_ip4 = NM.SettingIP4Config.new() + s_ip4.set_property(NM.SETTING_IP4_CONFIG_METHOD, "auto") - s_ip6 = NetworkManager.SettingIP6Config.new() - s_ip6.set_property(NetworkManager.SETTING_IP6_CONFIG_METHOD, "auto") + s_ip6 = NM.SettingIP6Config.new() + s_ip6.set_property(NM.SETTING_IP6_CONFIG_METHOD, "auto") profile.add_setting(s_con) profile.add_setting(s_ip4) @@ -86,7 +84,7 @@ if __name__ == "__main__": main_loop = GLib.MainLoop() # create RemoteSettings object - settings = NMClient.RemoteSettings.new(None); + settings = NM.RemoteSettings.new(None); # create a connection profile for NM con = create_profile(profile_name) diff --git a/examples/python/gi/device-state-ip4config.py b/examples/python/gi/device-state-ip4config.py index be19b9966d..faf0ef9422 100755 --- a/examples/python/gi/device-state-ip4config.py +++ b/examples/python/gi/device-state-ip4config.py @@ -21,7 +21,7 @@ # import sys -from gi.repository import GLib, NetworkManager, NMClient +from gi.repository import GLib, NM # # This example shows how to get NMIP4Config from NMDevice after it is activated. @@ -51,7 +51,7 @@ if __name__ == "__main__": sys.exit('Usage: %s <interface>' % sys.argv[0]) dev_iface = sys.argv[1] - c = NMClient.Client.new() + c = NM.Client.new() dev = c.get_device_by_iface(dev_iface) if dev is None: sys.exit('Device \'%s\' not found' % dev_iface) diff --git a/examples/python/gi/firewall-zone.py b/examples/python/gi/firewall-zone.py index 5e5eea919c..068ed89c71 100755 --- a/examples/python/gi/firewall-zone.py +++ b/examples/python/gi/firewall-zone.py @@ -20,7 +20,7 @@ # import sys -from gi.repository import GLib, NetworkManager, NMClient +from gi.repository import GLib, NM # # This example demonstrates how to get and change firewall zone in a @@ -32,7 +32,7 @@ from gi.repository import GLib, NetworkManager, NMClient # If you used D-Bus calls, you would call GetSettings() and then Update(). # # Links: -# https://developer.gnome.org/libnm-glib/0.9/ +# https://developer.gnome.org/libnm/1.0/ # https://wiki.gnome.org/GObjectIntrospection # https://wiki.gnome.org/PyGObject # @@ -78,7 +78,7 @@ if __name__ == "__main__": sys.exit('Usage: %s <connection name or UUID> [new zone]' % sys.argv[0]) main_loop = GLib.MainLoop() - settings = NMClient.RemoteSettings.new(None); + settings = NM.RemoteSettings.new(None); # Connections are read asynchronously, so we have to wait for the # 'settings' object to tell us that all connections have been read. diff --git a/examples/python/gi/get-active-connections.py b/examples/python/gi/get-active-connections.py index 13f0b0310e..a295be3038 100755 --- a/examples/python/gi/get-active-connections.py +++ b/examples/python/gi/get-active-connections.py @@ -21,10 +21,10 @@ # This example lists currently active connections -from gi.repository import GLib, NMClient +from gi.repository import GLib, NM if __name__ == "__main__": - client = NMClient.Client.new() + client = NM.Client.new() acons = client.get_active_connections() for ac in acons: print "%s (%s) - %s" % (ac.get_id(), ac.get_uuid(), ac.get_connection_type()) diff --git a/examples/python/gi/get_ips.py b/examples/python/gi/get_ips.py index 6903b6de20..9f1853f17e 100755 --- a/examples/python/gi/get_ips.py +++ b/examples/python/gi/get_ips.py @@ -21,7 +21,7 @@ # import sys, socket, struct -from gi.repository import GLib, NetworkManager, NMClient +from gi.repository import GLib, NM # # This example shows how to get addresses, routes and DNS information @@ -124,7 +124,7 @@ if __name__ == "__main__": sys.exit('Usage: %s <interface>' % sys.argv[0]) dev_iface = sys.argv[1] - c = NMClient.Client.new() + c = NM.Client.new() dev = c.get_device_by_iface(dev_iface) if dev is None: sys.exit('Device \'%s\' not found' % dev_iface) diff --git a/examples/python/gi/list-connections.py b/examples/python/gi/list-connections.py index b6452d35aa..b73d6a6c27 100755 --- a/examples/python/gi/list-connections.py +++ b/examples/python/gi/list-connections.py @@ -18,11 +18,11 @@ # Copyright (C) 2012 Red Hat, Inc. # -from gi.repository import GLib, NetworkManager, NMClient +from gi.repository import GLib, NM # This example asks settings service for all configured connections. -# Unfortunately, at this time since libnm-glib still makes heavy use of -# GValue and GHashTable (rather than GVariant), libnm-glib isn't fully +# Unfortunately, at this time since libnm still makes heavy use of +# GValue and GHashTable (rather than GVariant), libnm isn't fully # usable from GObject Introspection-ready languages. Most functions will # work fine, but e. g. nm_connection_to_hash() causes assertion failures. @@ -41,7 +41,7 @@ def connections_read(settings): if __name__ == "__main__": main_loop = GLib.MainLoop() - settings = NMClient.RemoteSettings.new(None); + settings = NM.RemoteSettings.new(None); # connections are read asynchronously, so we need to wait for the # settings object to tell us that it's read all connections diff --git a/examples/python/gi/show-wifi-networks.py b/examples/python/gi/show-wifi-networks.py index 9d9e347189..8f61cfcbe8 100755 --- a/examples/python/gi/show-wifi-networks.py +++ b/examples/python/gi/show-wifi-networks.py @@ -20,11 +20,11 @@ # Copyright (C) 2013 Red Hat, Inc. # -from gi.repository import NetworkManager, NMClient +from gi.repository import NM # # This example lists Wi-Fi access points NetworkManager scanned on Wi-Fi devices. -# It calls libnm-glib functions using GObject introspection. +# It calls libnm functions using GObject introspection. # # Note the second line of the file: coding=utf-8 # It is necessary because we use unicode characters and python would produce @@ -57,16 +57,16 @@ def print_ap_info(ap): print "SSID: %s" % (ap.get_ssid()) print "BSSID: %s" % (ap.get_bssid()) print "Frequency: %s" % (frequency) - print "Channel: %s" % (NetworkManager.utils_wifi_freq_to_channel(frequency)) + print "Channel: %s" % (NM.utils_wifi_freq_to_channel(frequency)) print "Strength: %s %s%%" % (signal_bars[(clamp(strength-5, 0, 99)+24)/25], strength) print if __name__ == "__main__": - nmc = NMClient.Client.new() + nmc = NM.Client.new() devs = nmc.get_devices() for dev in devs: - if dev.get_device_type() == NetworkManager.DeviceType.WIFI: + if dev.get_device_type() == NM.DeviceType.WIFI: print_device_info(dev) for ap in dev.get_access_points(): print_ap_info(ap) diff --git a/examples/python/gi/update-ip4-method.py b/examples/python/gi/update-ip4-method.py index 2fe12693be..e46f979be8 100755 --- a/examples/python/gi/update-ip4-method.py +++ b/examples/python/gi/update-ip4-method.py @@ -20,13 +20,13 @@ # # This example updates a connection's IPv4 method with the Update() method -# using the libnm-glib GObject-based convenience APIs. +# using the libnm GObject-based convenience APIs. # # Configuration settings are described at # https://developer.gnome.org/NetworkManager/0.9/ref-settings.html # -from gi.repository import GLib, NetworkManager, NMClient +from gi.repository import GLib, NM import sys, struct, socket def ip_to_int(ip_string): @@ -51,17 +51,17 @@ def connections_read_cb(settings, data): # add IPv4 setting if it doesn't yet exist s_ip4 = c.get_setting_ip4_config() if not s_ip4: - s_ip4 = NetworkManager.SettingIP4Config.new() + s_ip4 = NM.SettingIP4Config.new() c.add_setting(s_ip4) # set the method and change properties - s_ip4.set_property(NetworkManager.SETTING_IP4_CONFIG_METHOD, method) + s_ip4.set_property(NM.SETTING_IP4_CONFIG_METHOD, method) if method == "auto": # remove addresses s_ip4.clear_addresses() elif method == "manual": # Add the static IP address, prefix, and (optional) gateway - addr = NetworkManager.IP4Address.new() + addr = NM.IP4Address.new() addr.set_address(ip_to_int(sys.argv[3])) addr.set_prefix(int(sys.argv[4])) if len(sys.argv) == 6: @@ -89,7 +89,7 @@ if __name__ == "__main__": # create RemoteSettings object and attach to the "connections-read" signal # to wait for connections to be loaded asynchronously - settings = NMClient.RemoteSettings.new(None) + settings = NM.RemoteSettings.new(None) settings.connect('connections-read', connections_read_cb, (sys.argv[1], method, sys.argv)) main_loop.run() |
