def displayIP(connectionName):
    list = []

    if showIpMethod(connectionName) == 'manual':

        fullCommand = f'nmcli connection  show {connectionName} | grep -F ipv4.addresses: > /tmp/INipAddress'
        fullCommand = f'nmcli connection  show {connectionName} | grep -F ipv4.gateway: > /tmp/INgateway'
        fullCommand = f'nmcli connection  show {connectionName} | grep -F ipv4.dns:  >/tmp/INdns1'

        try:
            subprocess.run(fullCommand, check=True, shell=True)

        except subprocess.CalledProcessError:
            print("Error While fetching Data ")

        # fullCommand = f'cat /etc/sysconfig/network-scripts/ifcfg-{connectionName}| grep -F DNS2 > /tmp/dns2'
        # os.system(fullCommand)

        try:
            subprocess.run(fullCommand, check=True, shell=True)

        except subprocess.CalledProcessError:
            print("Error While fetching Data ")

        try:
            subprocess.run(fullCommand, check=True, shell=True)

        except subprocess.CalledProcessError:
            print("Error While fetching Data ")

        File = open('/tmp/INdns1', 'rt')
        txt = File.read()
        dns1 = txt.strip()
        dns = dns1.replace("ipv4.dns:", "-")
        dns = dns.replace(":", "")
        dns = dns.replace("-", "")
        dns = dns.strip()

        File = open('/tmp/INipAddress', 'rt')
        txt = File.read()
        ipAddress = txt.strip()
        ipAddress = ipAddress.replace("   ", ":")
        ipAddress = ipAddress.replace("ipv4.addresses:", "-")
        ipAddress = ipAddress.replace(":", "")
        ipAddress = ipAddress.replace("-", "")
        ipAddress = ipAddress.strip()

        File = open('/tmp/INgateway', 'rt')
        txt = File.read()
        gateway = txt.strip()
        gateway = gateway.replace("ipv4.gateway:", "-")
        gateway = gateway.replace(":", "")
        gateway = gateway.replace("-", "")
        gateway = gateway.strip()

        File = open('/tmp/INdns2', 'rt')
        txt = File.read()
        mask = txt.rstrip()
        dns2 = mask.replace("PREFIX=", "  ")

        coninfo = ipAddress + '-' + gateway + '-' + dns
        coninfo = coninfo.split("-")
        list.append(ipAddress)
        list.append(gateway)
        list.append(dns)
        list.append(dns2)

    else:

        fullCommand = f'nmcli connection  show {connectionName} | grep -F IP4.ADDRESS[1]: > /tmp/INipAddress2'

        try:
            subprocess.run(fullCommand, check=True, shell=True)

        except subprocess.CalledProcessError:
            print("Error While fetching Data ")

        # fullCommand = f'cat /etc/sysconfig/network-scripts/ifcfg-{connectionName}| grep -F DNS2 > /tmp/dns2'
        # os.system(fullCommand)

        fullCommand = f'nmcli connection  show {connectionName} | grep -F  IP4.GATEWAY: > /tmp/INgateway2'

        try:
            subprocess.run(fullCommand, check=True, shell=True)

        except subprocess.CalledProcessError:
            print("Error While fetching Data ")

        fullCommand = f'nmcli connection  show {connectionName} | grep -F  IP4.DNS[1]:  > /tmp/INdns12'

        try:
            subprocess.run(fullCommand, check=True, shell=True)

        except subprocess.CalledProcessError:
            print("Error While fetching Data ")

        fullCommand = f'nmcli connection  show {connectionName} | grep -F  IP4.DNS[2]:  > /tmp/INdns22'

        try:
            subprocess.run(fullCommand, check=True, shell=True)

        except subprocess.CalledProcessError:
            print("Error While fetching Data ")

        File = open('/tmp/INipAddress2', 'rt')
        txt2 = File.read()
        ip = txt2.strip()
        ip = ip.replace("IP4.ADDRESS[1]:", "-")
        ip = ip.replace(":", "")
        ip = ip.replace("-", "")
        ip = ip.strip()

        File = open('/tmp/INdns12', 'rt')
        txt1 = File.read()
        dns1 = txt1.strip()
        dns1 = dns1.replace("IP4.DNS[1]:", "-")
        dns1 = dns1.replace(":", "")
        dns1 = dns1.replace("-", "")
        dns1 = dns1.strip()

        File = open('/tmp/INgateway2', 'rt')
        txt3 = File.read()
        gatway = txt3.strip()
        gatway = gatway.replace("IP4.GATEWAY:", "-")
        gatway = gatway.replace(":", "")
        gatway = gatway.replace("-", "")
        gatway = gatway.strip()

        File = open('/tmp/INdns22', 'rt')
        txt4 = File.read()
        dns2 = txt4.strip()
        dns2 = dns2.replace("IP4.DNS[2]:", "-")
        dns2 = dns2.replace(":", "")
        dns2 = dns2.replace("-", "")
        dns2 = dns2.strip()
        try:
            fullCommand = 'rm -rf /tmp/IN*'
            subprocess.run(fullCommand, check=True, shell=True)

        except subprocess.CalledProcessError:
            print("Error While fetching Data ")

        coninfo2 = ip + '-' + gatway + '-' + dns1 + ',' + dns2
        list.append(ip)
        list.append(gatway)
        list.append(dns1)
        list.append(dns2)
        return list
def globalInfo():

    output=displayConnection()
    output.pop()
    turn=0
    for j in output:
        cm1 ='nmcli connection  show {} | grep -F connection.id:  >  /tmp/info-{}-'.format(j,output.index(j))
        cm2='nmcli connection  show {} | grep -F connection.type:  >> /tmp/info-{}-'.format(j,output.index(j))
        cm3 = 'nmcli connection  show {} | grep -F GENERAL.DEVICES: >> /tmp/info-{}-'.format(j, output.index(j))
        cm4 = 'nmcli connection  show {} | grep -F  connection.autoconnect: >> /tmp/info-{}-'.format(j, output.index(j))
        cm6=''
        if showIpMethod(j)=='auto':
            cm6='nmcli connection  show {}| grep -F IP4.ADDRESS[1]: >> /tmp/info-{}-'.format(j,output.index(j))
        else:
            cm6='nmcli connection  show {}| grep -F ipv4.addresses: >> /tmp/info-{}-'.format(j,output.index(j))

        try:
            os.system(cm1)
            os.system(cm2)
            os.system(cm3)
            os.system(cm4)
            #os.system(cm6)
            #os.system(cm3)
            #os.system(cm4)
        except os.error:
            return None
    c=[]
    cs=''
    try:
        fullCommand='rm -rf /tmp/allGlobalCon'
        subprocess.run(fullCommand, check=True, shell=True)

    except subprocess.CalledProcessError:
        print("Error While fetching Data ")

    for i in range(len(displayConnection())-1):
        f=open(f'/tmp/info-{i}-','rt')
        f=f.read()
        all=open('/tmp/allGlobalCon','a')
        all.write(f)
        all.close()
        try:
            fullCommand = f'rm -rf /tmp/info-{i}-'
            subprocess.run(fullCommand, check=True, shell=True)

        except subprocess.CalledProcessError:
            print("Error While fetching Data ")


    f=open('/tmp/allGlobalCon','rt')
    f=f.read()
    f=f.replace('ipv4.method',',')
    f=f.replace('connection.type:',',')
    f=f.replace('IP4.ADDRESS[1]:',',')
    f=f.replace('ipv4.addresses',',')

    f=f.replace('  ','')
    f=f.replace(':','')
    f=f.replace('802-3-ethernet','ethernet')
    f=f.replace('802-11-wireless','wifi')
    f=f.replace('GENERAL.STATE',',')
    f=f.replace('GENERAL.DEVICES',',')
    f=f.replace('connection.id',':')
    f=f.replace('\n','')
    here=f
    here=f.replace('GENERAL.DEVICES',',')
    here=f.replace('connection.autoconnect',',')

    File=open('/tmp/listCO','w')
    File.write(here)
    File.close()

    list_of_users = []
    with open("/tmp/listCO", mode='r') as passwd_content:
        passwd_content=passwd_content.read()
        each_user2 = passwd_content.split(":")
        each_user2.pop(0)
    for i in each_user2:

        k = i.split(',')
        list_of_users.append(k)

    return list_of_users