check_supervisord.py
def parse_options():
    """
    Commandline options arguments parsing.

    :return: parsed commandline arguments.
    :rtype: optparse.Values.
    """

    version = "%%prog {version}".format(version=__version__)
    parser = OptionParser(version=version)
    parser.add_option(
        "-s", "--server", action="store", dest="server",
        type="string", default="", metavar="SERVER",
        help="server name, IP address or unix socket path"
    )
    parser.add_option(
        "-p", "--port", action="store", type="int", dest="port",
        default=9001, metavar="PORT", help="port number"
    )
    parser.add_option(
        "-P", "--programs", action="store", dest="programs", type="string", default="",
        metavar="PROGRAMS", help="comma separated programs list, or empty for all programs in supervisord response"
    )
    parser.add_option(
        "-u", "--username", action="store", dest="username", type="string", default="",
        metavar="USERNAME", help="supervisord user"
    )
    parser.add_option(
        "-S", "--password", action="store", dest="password", type="string", default="",
        metavar="PASSWORD", help="supervisord user password"
    )
    parser.add_option(
        "-q", "--quiet", metavar="QUIET", action="store_true", default=False, dest="quiet", help="be quiet"
    )
    parser.add_option(
        "--stopped-state", action="store", dest="stopped_state", type="choice", choices=EXIT_CODES.keys(), default=EXIT_CODE_OK,
        metavar="STOPPED_STATE", help="stopped state"
    )
    parser.add_option(
        "--network-errors-exit-code", action="store", dest="network_errors_exit_code", type="choice", choices=EXIT_CODES.keys(), default=EXIT_CODE_UNKNOWN,
        metavar="NETWORK_ERRORS_EXIT_CODE", help="network errors exit code"
    )

    options = parser.parse_args(sys.argv)[0]
    STATE2TEMPLATE[STATE_STOPPED] = options.stopped_state  # update stopped state value from command line argument

    # check mandatory command line options supplied
    if not options.server:
        parser.error("Required server address option missing")
    if options.username and not options.password:
        parser.error("Required supervisord user password")

    return options
def parse_options():
    """
    Commandline options arguments parsing.

    :return: parsed commandline arguments.
    :rtype: optparse.Values.
    """

    version = "%%prog {version}".format(version=__version__)
    parser = OptionParser(version=version)
    parser.add_option(
        "-s", "--server", action="store", dest="server",
        type="string", default="", metavar="SERVER",
        help="server name, IP address or unix socket path"
    )
    parser.add_option(
        "-p", "--port", action="store", type="int", dest="port",
        default=9001, metavar="PORT", help="port number"
    )
    parser.add_option(
        "-P", "--programs", action="store", dest="programs", type="string", default="",
        metavar="PROGRAMS", help="comma separated programs list, or empty for all programs in supervisord response"
    )
    parser.add_option(
        "-u", "--username", action="store", dest="username", type="string", default="",
        metavar="USERNAME", help="supervisord user"
    )
    parser.add_option(
        "-S", "--password", action="store", dest="password", type="string", default="",
        metavar="PASSWORD", help="supervisord user password"
    )
    parser.add_option(
        "-q", "--quiet", metavar="QUIET", action="store_true", default=False, dest="quiet", help="be quiet"
    )
    parser.add_option(
        "--stopped-state", action="store", dest="stopped_state", type="choice", choices=EXIT_CODES.keys(), default=EXIT_CODE_OK,
        metavar="STOPPED_STATE", help="stopped state"
    )
    parser.add_option(
        "--network-errors-exit-code", action="store", dest="network_errors_exit_code", type="choice", choices=EXIT_CODES.keys(), default=EXIT_CODE_UNKNOWN,
        metavar="NETWORK_ERRORS_EXIT_CODE", help="network errors exit code"
    )

    options = parser.parse_args(sys.argv)[0]
    STATE2TEMPLATE[STATE_STOPPED] = options.stopped_state  # update stopped state value from command line argument

    # check mandatory command line options supplied
    if not options.server:
        parser.error("Required server address option missing")
    if options.username and not options.password:
        parser.error("Required supervisord user password")

    return options
Commandline options arguments parsing.

    :return: parsed commandline arguments.
    :rtype: optparse.Values.