Пример #1
0
def main():
    parser = OptionParser(usage="Usage: %prog [options] [[--] <application> [<args>]]")
    collection_group = OptionGroup(parser, "Collection options")
    collection_group.add_option("--file",
                                metavar="FILE",
                                dest="file",
                                help="")

    collection_group.add_option("--func",
                                metavar="OUT",
                                dest="function",
                                help="")

    collection_group.add_option("--out",
                                metavar="OUT",
                                dest="out",
                                help="")

    collection_group.add_option("--cache",
                                metavar="CACHE",
                                dest="cache",
                                help="")

    collection_group.add_option("--format",
                                metavar="FORMAT",
                                dest="format",
                                help="")

    parser.add_option_group(collection_group)

    (options, arguments) = parser.parse_args()
    if options.file:
        if not os.path.exists(options.file):
            parser.error("file not found")
    else:
        parser.error("file not specified")

    info = HpccInfo('xstftool', options)
    parser = Parser(options.format, info, options.out, options.cache)

    print datetime.datetime.now().ctime() + ' Start'
    if options.cache is None:
        parser.parse()
    else:
        if not parser.read_cache():
            parser.parse()

    parser.to_print()
    print "\n" + datetime.datetime.now().ctime() + ' End'
    return 0