Пример #1
0
def parse_command_line():
    parser = OptParser(option_class=OptChecker,
                description=' '.join(_description.split()))
    parser.setHelp(_help)
    parser.set_usage('%prog ' + _usage)
    parser.remove_option('-h')
    
    parser.add_option('--start', action='store_true',
                        help='Start the Greenplum Performance Monitor web server.')
    parser.add_option('--stop', action='store_true',
                      help='Stop the Greenplum Performance Monitor web server.')
    parser.add_option('--restart', action='store_true',
                      help='Restart the Greenplum Performance Monitor web server.')                        
    parser.add_option('--status', action='store_true',
                      help='Display the status of the Gerrnplum Performance Monitor web server.')
    parser.add_option('--setup', action='store_true',
                      help='Setup the Greenplum Performance Monitor web server.')
    parser.add_option('--version', action='store_true',
                       help='Display version information')
    parser.add_option('--upgrade', action='store_true',
                      help='Upgrade a previous installation of the Greenplum Performance Monitors web UI')
        
    parser.set_defaults(verbose=False,filters=[], slice=(None, None))
    
    # Parse the command line arguments
    (options, args) = parser.parse_args()

    if options.version:
        version()
        sys.exit(0)
    
    # check for too many options
    opt_count = 0
    if options.start:
        opt_count+=1
    if options.stop:
        opt_count+=1
    if options.setup:
        opt_count+=1
    if options.upgrade:
        opt_count+=1
    if options.status:
        opt_count+=1

    if opt_count > 1:
        parser.print_help()
        parser.exit()
    
    return options, args