summaryrefslogtreecommitdiff
path: root/examples/python/dbus/add-connection-compat.py
diff options
context:
space:
mode:
authorSayed Shah <sayshah@redhat.com>2020-06-30 16:21:00 -0400
committerThomas Haller <thaller@redhat.com>2020-08-03 18:37:43 +0200
commit7baf615eaa27ec38755fcaaf7430b0075087dc60 (patch)
tree524562bcb734e024dc4161e46c9b92f5ed025e37 /examples/python/dbus/add-connection-compat.py
parent4d878d7012cd9dc031682ef5e5b025081427325b (diff)
downloadNetworkManager-7baf615eaa27ec38755fcaaf7430b0075087dc60.tar.gz
all: changes from python 2 syntax to python3 and removing dead code
There were python 2 methods that are not used anymore so now it's in python 3. Added helper fuctions so that the code is more clear https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/540
Diffstat (limited to 'examples/python/dbus/add-connection-compat.py')
-rwxr-xr-xexamples/python/dbus/add-connection-compat.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/examples/python/dbus/add-connection-compat.py b/examples/python/dbus/add-connection-compat.py
index 6acec734bc..2661eccb40 100755
--- a/examples/python/dbus/add-connection-compat.py
+++ b/examples/python/dbus/add-connection-compat.py
@@ -16,16 +16,14 @@
import socket, struct, dbus, uuid
-# Helper functions
+
def ip_to_int(ip_string):
return struct.unpack("=I", socket.inet_aton(ip_string))[0]
-def int_to_ip(ip_int):
- return socket.inet_ntoa(struct.pack("=I", ip_int))
-
-
+# full duplex
s_wired = dbus.Dictionary({"duplex": "full"})
+
s_con = dbus.Dictionary(
{"type": "802-3-ethernet", "uuid": str(uuid.uuid4()), "id": "MyConnectionExample"}
)
@@ -47,7 +45,6 @@ con = dbus.Dictionary(
{"802-3-ethernet": s_wired, "connection": s_con, "ipv4": s_ip4, "ipv6": s_ip6}
)
-
print("Creating connection:", s_con["id"], "-", s_con["uuid"])
bus = dbus.SystemBus()