lundi 3 juillet 2017

IPy validate IP vs FQDN if statement fails

When running this if I enter an IP its great however when running it and entering a string it doe not reach the esle statement

from IPy import IP
while True:
    try:
        #Ask for IP or FQDN
        fqdn_or_ip = input("Please enter the server FQDN or IP ADDRESS:   ")
        #USER REVIEWS ENTRY
        print(fqdn_or_ip + "\n")
        if IP(fqdn_or_ip):
            print("1. YES")
            print("2. NO")
            socket_validate = int(input("Looks like you entered an IP address correct?   "))
            if (socket_validate == 1):
                print("GREAT!")
                break
            else:
                continue
        else:
            print("1. YES")
            print("2. NO")
            socket_validate = int(input("Looks like you entered" + fqdn_or_ip + " correct?   "))
            if (socket_validate == 1):
                print("GREAT! LET'S MOVE ON TO THE SERVERS.")
                break
            else:
                continue
    except ValueError:
        print("Sorry thats not valid try again")
        continue

Aucun commentaire:

Enregistrer un commentaire