ICMP Ping/ICMPPing.py
def start_ping(*fuzzy_search_list):
    """ Enter the ping command, start test and catch the exceptions.

    This function simulates ping, an executable command on the
    Windows operating system. It will catch a wrong command before a test
    and print a warning.
    Args:
        :param fuzzy_search_list: Ignore case to find the correct command.

    Raises:
        socket.gaierror: Hostname might be wrong.
        IndexError: Optional argument is empty.
        ValueError: the parameter for option is wrong.
    """
    start_flag = True
    while start_flag:
        command = input(os.getcwd() + ">" +
                        os.path.basename(sys.argv[0]) + ">").split()
        cmd_len = len(command)
        if cmd_len == 0:
            # Okay, pass.
            continue
        elif cmd_len == 1:
            if command[0] == "exit":
                start_flag = False
            else:
                print("Command error.")
        elif cmd_len == 2:
            if command[0] in fuzzy_search_list:
                try:
                    # Default measurement count and timeout.
                    ping(command[1])
                except socket.gaierror:
                    print("Ping Request Could not Find Host. " +
                          "Please Check the Name and Try again.")
        elif cmd_len in range(3,5):
            if command[0] in fuzzy_search_list:
                try:
                    if command[2] == "-n":
                        # Default timeout and configurable measurement count.
                        ping(command[1], command[3])
                    elif command[2] == "-w":
                        # Default measurement count and configurable timeout.
                        ping(command[1], "4", command[5])
                    else:
                        print("Option {op} is incorrect.".format(op = command[2]))
                except IndexError:
                    print("Must set a value for option {op}.".format(op = command[2]))
                except ValueError:
                    print("Bad value for option {op}, ".format(op = command[2]), end="")
                    print("valid range is from 1 to 4294967295.")
                except socket.gaierror:
                    print("Ping Request Could not Find Host. " +
                          "Please Check the Name and Try again.")
            else:
                print("Command error.")
        elif cmd_len in range(5,7):
            if command[0] in fuzzy_search_list:
                # Configurable measurement count and timeout.
                if command[2] == "-n" and command[4] == "-w":
                    try:
                        ping(command[1], command[3], command[5])
                    except IndexError:
                        print("Must set a value for option ",command[4],".")
                    except ValueError:
                        op = command[2] if command[3].isdigit() is False else command[5]
                        print(
                            "Bad value for option {op}, ".format(op = op)+
                            "valid range is from 1 to 4294967295.")
                    except socket.gaierror:
                        print("Ping Request Could not Find Host. " +
                              "Please Check the Name and Try again.")
                else:
                    print("Command error.")
            else:
                print("Command error.")
        else:
            print("Command error.")
        # Tricky tip: leave the cursor at the end.
        time.sleep(0.3)
 Enter the ping command, start test and catch the exceptions.

    This function simulates ping, an executable command on the
    Windows operating system. It will catch a wrong command before a test
    and print a warning.
    Args:
        :param fuzzy_search_list: Ignore case to find the correct command.

    Raises:
        socket.gaierror: Hostname might be wrong.
        IndexError: Optional argument is empty.
        ValueError: the parameter for option is wrong.
    
Enter the ping command, start test and catch the exceptions.
This function simulates ping, an executable command on the
Windows operating system. It will catch a wrong command before a test
and print a warning.
Enter the ping command start test and catch the exceptions . This function simulates ping an executable command on the Windows operating system . It will catch a wrong command before a test and print a warning .
def start_ping(*fuzzy_search_list):
    start_flag = True
    while start_flag:
        command = input(os.getcwd() + ">" +
                        os.path.basename(sys.argv[0]) + ">").split()
        cmd_len = len(command)
        if cmd_len == 0:
            continue
        elif cmd_len == 1:
            if command[0] == "exit":
                start_flag = False
            else:
                print("Command error.")
        elif cmd_len == 2:
            if command[0] in fuzzy_search_list:
                try:
                    ping(command[1])
                except socket.gaierror:
                    print("Ping Request Could not Find Host. " +
                          "Please Check the Name and Try again.")
        elif cmd_len in range(3,5):
            if command[0] in fuzzy_search_list:
                try:
                    if command[2] == "-n":
                        ping(command[1], command[3])
                    elif command[2] == "-w":
                        ping(command[1], "4", command[5])
                    else:
                        print("Option {op} is incorrect.".format(op = command[2]))
                except IndexError:
                    print("Must set a value for option {op}.".format(op = command[2]))
                except ValueError:
                    print("Bad value for option {op}, ".format(op = command[2]), end="")
                    print("valid range is from 1 to 4294967295.")
                except socket.gaierror:
                    print("Ping Request Could not Find Host. " +
                          "Please Check the Name and Try again.")
            else:
                print("Command error.")
        elif cmd_len in range(5,7):
            if command[0] in fuzzy_search_list:
                if command[2] == "-n" and command[4] == "-w":
                    try:
                        ping(command[1], command[3], command[5])
                    except IndexError:
                        print("Must set a value for option ",command[4],".")
                    except ValueError:
                        op = command[2] if command[3].isdigit() is False else command[5]
                        print(
                            "Bad value for option {op}, ".format(op = op)+
                            "valid range is from 1 to 4294967295.")
                    except socket.gaierror:
                        print("Ping Request Could not Find Host. " +
                              "Please Check the Name and Try again.")
                else:
                    print("Command error.")
            else:
                print("Command error.")
        else:
            print("Command error.")
        time.sleep(0.3)
def start_ping ( * fuzzy_search_list ) : start_flag = True while start_flag : command = input ( os . getcwd ( ) + ">" + os . path . basename ( sys . argv [ 0 ] ) + ">" ) . split ( ) cmd_len = len ( command ) if cmd_len == 0 : continue elif cmd_len == 1 : if command [ 0 ] == "exit" : start_flag = False else : print ( "Command error." ) elif cmd_len == 2 : if command [ 0 ] in fuzzy_search_list : try : ping ( command [ 1 ] ) except socket . gaierror : print ( "Ping Request Could not Find Host. " + "Please Check the Name and Try again." ) elif cmd_len in range ( 3 , 5 ) : if command [ 0 ] in fuzzy_search_list : try : if command [ 2 ] == "-n" : ping ( command [ 1 ] , command [ 3 ] ) elif command [ 2 ] == "-w" : ping ( command [ 1 ] , "4" , command [ 5 ] ) else : print ( "Option {op} is incorrect." . format ( op = command [ 2 ] ) ) except IndexError : print ( "Must set a value for option {op}." . format ( op = command [ 2 ] ) ) except ValueError : print ( "Bad value for option {op}, " . format ( op = command [ 2 ] ) , end = "" ) print ( "valid range is from 1 to 4294967295." ) except socket . gaierror : print ( "Ping Request Could not Find Host. " + "Please Check the Name and Try again." ) else : print ( "Command error." ) elif cmd_len in range ( 5 , 7 ) : if command [ 0 ] in fuzzy_search_list : if command [ 2 ] == "-n" and command [ 4 ] == "-w" : try : ping ( command [ 1 ] , command [ 3 ] , command [ 5 ] ) except IndexError : print ( "Must set a value for option " , command [ 4 ] , "." ) except ValueError : op = command [ 2 ] if command [ 3 ] . isdigit ( ) is False else command [ 5 ] print ( "Bad value for option {op}, " . format ( op = op ) + "valid range is from 1 to 4294967295." ) except socket . gaierror : print ( "Ping Request Could not Find Host. " + "Please Check the Name and Try again." ) else : print ( "Command error." ) else : print ( "Command error." ) else : print ( "Command error." ) time . sleep ( 0.3 )
Enter the ping command, start test and catch the exceptions.
Enter the ping command start test and catch the exceptions .
""" Enter the ping command, start test and catch the exceptions.

    This function simulates ping, an executable command on the
    Windows operating system. It will catch a wrong command before a test
    and print a warning.
    Args:
        :param fuzzy_search_list: Ignore case to find the correct command.

    Raises:
        socket.gaierror: Hostname might be wrong.
        IndexError: Optional argument is empty.
        ValueError: the parameter for option is wrong.
    """ # Okay, pass. # Default measurement count and timeout. # Default timeout and configurable measurement count. # Default measurement count and configurable timeout. # Configurable measurement count and timeout. # Tricky tip: leave the cursor at the end.
Hostname might be wrong.
Hostname might be wrong .
socket.gaierror
Optional argument is empty.
Optional argument is empty .
IndexError
the parameter for option is wrong.
the parameter for option is wrong .
ValueError
param fuzzy_search_list: Ignore case to find the correct command.
param fuzzy_search_list : Ignore case to find the correct command .