diff options
| author | Michael Biebl <biebl@debian.org> | 2018-06-04 00:07:45 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-06-04 00:07:45 +0200 |
| commit | 04bc9e1cd3544445d883ad29ea108c1645c8e7b7 (patch) | |
| tree | d10c354b1b980ca8a7b9e48ec9019e8ed88bde2b /examples/python/gi | |
| parent | ee9c73a923909e23a649407be77e25235d769e25 (diff) | |
New upstream version 1.11.4 upstream/1.11.4
Diffstat (limited to 'examples/python/gi')
| -rwxr-xr-x | examples/python/gi/add_connection.py | 4 | ||||
| -rwxr-xr-x | examples/python/gi/deactivate-all.py | 2 | ||||
| -rwxr-xr-x | examples/python/gi/device-state-ip4config.py | 14 | ||||
| -rwxr-xr-x | examples/python/gi/get-active-connections.py | 4 | ||||
| -rwxr-xr-x | examples/python/gi/get_ips.py | 12 | ||||
| -rwxr-xr-x | examples/python/gi/list-connections.py | 6 | ||||
| -rwxr-xr-x | examples/python/gi/show-wifi-networks.py | 24 | ||||
| -rwxr-xr-x | examples/python/gi/update-ip4-method.py | 6 |
8 files changed, 36 insertions, 36 deletions
diff --git a/examples/python/gi/add_connection.py b/examples/python/gi/add_connection.py index cfb40a9a..f5b5e63c 100755 --- a/examples/python/gi/add_connection.py +++ b/examples/python/gi/add_connection.py @@ -37,7 +37,7 @@ import sys, uuid main_loop = None def print_values(setting, key, value, flags, data): - print " %s.%s: %s" % (setting.get_name(), key, value) + print(" %s.%s: %s" % (setting.get_name(), key, value)) # create an Ethernet connection and return it def create_profile(name): @@ -70,7 +70,7 @@ def added_cb(client, result, data): try: client.add_connection_finish(result) print("The connection profile has been succesfully added to NetworkManager.") - except Exception, e: + except Exception as e: sys.stderr.write("Error: %s\n" % e) main_loop.quit() diff --git a/examples/python/gi/deactivate-all.py b/examples/python/gi/deactivate-all.py index 59842ac2..a4588522 100755 --- a/examples/python/gi/deactivate-all.py +++ b/examples/python/gi/deactivate-all.py @@ -78,6 +78,6 @@ if __name__ == "__main__": try: client.deactivate_connection(ac, None) sys.stdout.write("\033[32m -> succeeded\033[0m\n") - except Exception, e: + except Exception as e: sys.stderr.write("\033[31m -> failed\033[0m (%s)\n" % e.message) diff --git a/examples/python/gi/device-state-ip4config.py b/examples/python/gi/device-state-ip4config.py index 2a4a6221..b92a7b09 100755 --- a/examples/python/gi/device-state-ip4config.py +++ b/examples/python/gi/device-state-ip4config.py @@ -27,22 +27,22 @@ from gi.repository import GLib, NM # # This example shows how to get NMIP4Config from NMDevice after it is activated. -# +# # We listen to notify::ip4-config glib signal. This signal is trigered by D-Bus # PropertiesChanged for IP4Config that comes after StateChanged for NMDevice. # main_loop = None - + def do_notify(self, property): - print "notify: %s" % property + print("notify: %s" % property) ip4cfg = self.get_ip4_config() if ip4cfg is not None: - print "ip4-config: %s" % ip4cfg.get_path() + print("ip4-config: %s" % ip4cfg.get_path()) main_loop.quit() def state_changed(obj, arg1, arg2, arg3): - print "State changed: New: %d, Old: %d, Reason: %d" % (arg1, arg2, arg3) + print("State changed: New: %d, Old: %d, Reason: %d" % (arg1, arg2, arg3)) # Device is connected if arg1 == 100: obj.connect('notify::ip4-config', do_notify) @@ -57,8 +57,8 @@ if __name__ == "__main__": dev = c.get_device_by_iface(dev_iface) if dev is None: sys.exit('Device \'%s\' not found' % dev_iface) - print "Device: %s - %s" % (dev_iface, dev.get_device_type().value_name) - print "---------------------------------------" + print("Device: %s - %s" % (dev_iface, dev.get_device_type().value_name)) + print("---------------------------------------") dev.connect('state-changed', state_changed) main_loop = GLib.MainLoop() diff --git a/examples/python/gi/get-active-connections.py b/examples/python/gi/get-active-connections.py index 22c9eb4a..cee579f9 100755 --- a/examples/python/gi/get-active-connections.py +++ b/examples/python/gi/get-active-connections.py @@ -29,8 +29,8 @@ if __name__ == "__main__": client = NM.Client.new(None) acons = client.get_active_connections() for ac in acons: - print "%s (%s) - %s" % (ac.get_id(), ac.get_uuid(), ac.get_connection_type()) + print("%s (%s) - %s" % (ac.get_id(), ac.get_uuid(), ac.get_connection_type())) if len(acons) == 0: - print "No active connections" + print("No active connections") diff --git a/examples/python/gi/get_ips.py b/examples/python/gi/get_ips.py index 77e1d171..66d154f2 100755 --- a/examples/python/gi/get_ips.py +++ b/examples/python/gi/get_ips.py @@ -116,8 +116,8 @@ if __name__ == "__main__": dev = c.get_device_by_iface(dev_iface) if dev is None: sys.exit('Device \'%s\' not found' % dev_iface) - print "Device: %s - %s" % (dev_iface, dev.get_device_type().value_name) - print "---------------------------------------" + print("Device: %s - %s" % (dev_iface, dev.get_device_type().value_name)) + print("---------------------------------------") print("IPv4 addresses:") print("---------------") @@ -134,7 +134,7 @@ if __name__ == "__main__": show_routes(dev, socket.AF_INET) print - print "IPv6 addresses:" + print("IPv6 addresses:") print("---------------") show_addresses(dev, socket.AF_INET6) print @@ -144,17 +144,17 @@ if __name__ == "__main__": show_gateway(dev, socket.AF_INET6) print - print "IPv6 routes:" + print("IPv6 routes:") print("------------") show_routes(dev, socket.AF_INET6) print - print "IPv4 DNS:" + print("IPv4 DNS:") print("------------") show_dns(dev, socket.AF_INET) print - print "IPv6 DNS:" + print("IPv6 DNS:") print("------------") show_dns(dev, socket.AF_INET6) print diff --git a/examples/python/gi/list-connections.py b/examples/python/gi/list-connections.py index 32ea70f5..2139e8c1 100755 --- a/examples/python/gi/list-connections.py +++ b/examples/python/gi/list-connections.py @@ -27,7 +27,7 @@ from gi.repository import NM # This example asks settings service for all configured connections. def print_values(setting, key, value, flags, data): - print " %s.%s: %s" % (setting.get_name(), key, value) + print(" %s.%s: %s" % (setting.get_name(), key, value)) if __name__ == "__main__": # create Client object @@ -38,7 +38,7 @@ if __name__ == "__main__": # print the connections' details for c in connections: - print "=== %s : %s ===" % (c.get_id(), c.get_path()) + print("=== %s : %s ===" % (c.get_id(), c.get_path())) c.for_each_setting_value(print_values, None) - print "\n" + print("\n") diff --git a/examples/python/gi/show-wifi-networks.py b/examples/python/gi/show-wifi-networks.py index db49b555..4c7a126f 100755 --- a/examples/python/gi/show-wifi-networks.py +++ b/examples/python/gi/show-wifi-networks.py @@ -49,8 +49,8 @@ def print_device_info(device): if active_ap is not None: ssid = ssid_to_utf8(active_ap) info = "Device: %s | Driver: %s | Active AP: %s" % (dev.get_iface(), dev.get_driver(), ssid) - print info - print '=' * len(info) + print(info) + print('=' * len(info)) def mode_to_string(mode): if mode == getattr(NM, '80211Mode').INFRA: @@ -114,16 +114,16 @@ def print_ap_info(ap): flags = ap.get_flags() wpa_flags = ap.get_wpa_flags() rsn_flags = ap.get_rsn_flags() - print "SSID: %s" % (ssid_to_utf8(ap)) - print "BSSID: %s" % (ap.get_bssid()) - print "Frequency: %s" % (frequency) - print "Channel: %s" % (NM.utils_wifi_freq_to_channel(frequency)) - print "Mode: %s" % (mode_to_string(ap.get_mode())) - print "Flags: %s" % (flags_to_string(flags)) - print "WPA flags: %s" % (security_flags_to_string(wpa_flags)) - print "RSN flags: %s" % (security_flags_to_string(rsn_flags)) - print "Security: %s" % (flags_to_security(flags, wpa_flags, rsn_flags)) - print "Strength: %s %s%%" % (NM.utils_wifi_strength_bars(strength), strength) + print("SSID: %s" % (ssid_to_utf8(ap))) + print("BSSID: %s" % (ap.get_bssid())) + print("Frequency: %s" % (frequency)) + print("Channel: %s" % (NM.utils_wifi_freq_to_channel(frequency))) + print("Mode: %s" % (mode_to_string(ap.get_mode()))) + print("Flags: %s" % (flags_to_string(flags))) + print("WPA flags: %s" % (security_flags_to_string(wpa_flags))) + print("RSN flags: %s" % (security_flags_to_string(rsn_flags))) + print("Security: %s" % (flags_to_security(flags, wpa_flags, rsn_flags))) + print("Strength: %s %s%%" % (NM.utils_wifi_strength_bars(strength), strength)) print if __name__ == "__main__": diff --git a/examples/python/gi/update-ip4-method.py b/examples/python/gi/update-ip4-method.py index 12124599..3b2df72e 100755 --- a/examples/python/gi/update-ip4-method.py +++ b/examples/python/gi/update-ip4-method.py @@ -35,12 +35,12 @@ import sys, socket if __name__ == "__main__": # parse and validate arguments if len(sys.argv) < 3: - print "Usage: %s <uuid> <auto|static> [address prefix gateway]" % sys.argv[0] + print("Usage: %s <uuid> <auto|static> [address prefix gateway]" % sys.argv[0]) sys.exit(1) method = sys.argv[2] if (method == "static" or method == "manual") and len(sys.argv) < 5: - print "Usage: %s %s static address prefix [gateway]" % (sys.argv[0], sys.argv[1]) + print("Usage: %s %s static address prefix [gateway]" % (sys.argv[0], sys.argv[1])) sys.exit(1) uuid = sys.argv[1] @@ -81,7 +81,7 @@ if __name__ == "__main__": try: c.commit_changes(True, None) print("The connection profile has been updated.") - except Exception, e: + except Exception as e: sys.stderr.write("Error: %s\n" % e) break |