Iterating command switches from a data file - have a working solution but it seems inefficient

News arobert at townisp.com
Thu Apr 13 08:57:11 EDT 2006


Hi everyone,

Just to be complete, my final solution was:

    parser = OptionParser()

    parser.add_option("-m","--qmanager", dest="qmanager",
                    help="\t\tQueue Manager to inquire against"),

    parser.add_option("-s","--server", dest="host",
                    help="\t\tHost the que manager resides on"),

    parser.add_option("-c","--check",  dest="check",
                    help="\t\tTest object if it is less/equal/greater"),

    parser.add_option("-p","--port", type="string", dest="port",
                    help="\t\tPort queue manager listens on"),

    parser.add_option("-o","--object", dest="object",
                    help="\t\tQueue object being inquired on"),

    parser.add_option("-k", "--key",dest="key",
                    help="\t\tobject attribute to be inquired about"),

    parser.add_option("-t","--to", type="string",dest="mto",
                    help="\t\te-mail address the report will go to"),

    parser.add_option("-q","--quiet", action="store_false",dest="quiet",
                    help="\t\toptional - just returns the value"),

    parser.add_option("-f", "--file",
                    action="store", type="string", dest="filename",
                    help="Pull command strings from FILE",
                    metavar="FILE")

    parser.add_option("-d","--display",
                      action="store_false",dest="report",
                      help="\t\toptional - use sends output to e-mail")

    (options, args) = parser.parse_args()

    if options.filename is not None:
	    line = use_file()
	    (options,args) = parser.parse_args(line.split())



More information about the Python-list mailing list