all: reformat python files with python black

Part of !537.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/537
This commit is contained in:
Sayed Shah
2020-06-09 16:28:32 -04:00
committed by Thomas Haller
parent b6febb0fd0
commit be822b52e6
44 changed files with 3179 additions and 1961 deletions

View File

@@ -6,7 +6,8 @@
import sys, socket
import gi
gi.require_version('NM', '1.0')
gi.require_version("NM", "1.0")
from gi.repository import NM
#
@@ -14,11 +15,12 @@ from gi.repository import NM
# from NMIP4Config and NMIP6Config (got out of NMDevice)
#
def show_addresses(dev, family):
if (family == socket.AF_INET):
ip_cfg = dev.get_ip4_config()
if family == socket.AF_INET:
ip_cfg = dev.get_ip4_config()
else:
ip_cfg = dev.get_ip6_config()
ip_cfg = dev.get_ip6_config()
if ip_cfg is None:
print("None")
@@ -35,8 +37,9 @@ def show_addresses(dev, family):
print("%s/%d") % (addr, prefix)
def show_gateway(dev, family):
if (family == socket.AF_INET):
if family == socket.AF_INET:
ip_cfg = dev.get_ip4_config()
else:
ip_cfg = dev.get_ip6_config()
@@ -45,16 +48,17 @@ def show_gateway(dev, family):
gw = "None"
else:
gw = ip_cfg.get_gateway()
if gw == '':
if gw == "":
gw = "None"
print(gw)
def show_routes(dev, family):
if (family == socket.AF_INET):
ip_cfg = dev.get_ip4_config()
if family == socket.AF_INET:
ip_cfg = dev.get_ip4_config()
else:
ip_cfg = dev.get_ip6_config()
ip_cfg = dev.get_ip6_config()
if ip_cfg is None:
print("None")
@@ -75,31 +79,31 @@ def show_routes(dev, family):
def show_dns(dev, family):
if (family == socket.AF_INET):
ip_cfg = dev.get_ip4_config()
if family == socket.AF_INET:
ip_cfg = dev.get_ip4_config()
else:
ip_cfg = dev.get_ip6_config()
ip_cfg = dev.get_ip6_config()
if ip_cfg is None:
print("None")
return
print ("Nameservers: %s") % (ip_cfg.get_nameservers())
print ("Domains: %s") % (ip_cfg.get_domains())
print ("Searches: %s") % (ip_cfg.get_searches())
if (family == socket.AF_INET):
print ("WINS: %s") % (ip_cfg.get_wins_servers())
print("Nameservers: %s") % (ip_cfg.get_nameservers())
print("Domains: %s") % (ip_cfg.get_domains())
print("Searches: %s") % (ip_cfg.get_searches())
if family == socket.AF_INET:
print("WINS: %s") % (ip_cfg.get_wins_servers())
if __name__ == "__main__":
if len(sys.argv) != 2:
sys.exit('Usage: %s <interface>' % sys.argv[0])
sys.exit("Usage: %s <interface>" % sys.argv[0])
dev_iface = sys.argv[1]
c = NM.Client.new(None)
dev = c.get_device_by_iface(dev_iface)
if dev is None:
sys.exit('Device \'%s\' not found' % dev_iface)
sys.exit("Device '%s' not found" % dev_iface)
print("Device: %s - %s" % (dev_iface, dev.get_device_type().value_name))
print("---------------------------------------")
@@ -142,4 +146,3 @@ if __name__ == "__main__":
print("------------")
show_dns(dev, socket.AF_INET6)
print