Exemple #1
0
def main_list(args=None, func=_print_simulation_list):
    """Retrieves list of all simulations, by default prints in human readable format.
    """
    op = optparse.OptionParser(usage="USAGE: %prog [options] CONFIG_FILE",
                               description=main_list.__doc__)
    add_options(op)
    add_json_option(op)
    (options, args) = op.parse_args(args)

    if len(args) != 1:
        op.error('expecting 1 argument')
    if options.json:
        func = _print_json

    configFile = _open_config(args[0])
    query = {}

    if options.verbose:
        query['verbose'] = options.verbose

    options.page = 1
    content = get_page(configFile, SECTION, **query)
    data = load_pages_json([content])
    if func:
        func(data, options.verbose)

    return data
def main_list(args=None, func=_print_numbered_lines):
    """Prints human readable listing of all session GUIDs.
    """
    op = optparse.OptionParser(usage="USAGE: %prog [options] CONFIG_FILE",
                               description=main_list.__doc__)

    add_options(op)
    add_json_option(op)
    (options, args) = op.parse_args(args)
    try:
        configFile = _open_config(*args)
    except Exception, ex:
        op.error(ex.Message)
def main(args=None, func=_print_numbered_lines):
    """List all Consumer resources, by default print in human readable format.
    """
    op = optparse.OptionParser(usage="USAGE: %prog [options] CONFIG_FILE",
                               description=main.__doc__)

    # add_options(op)
    op.add_option("-v",
                  "--verbose",
                  action="store_true",
                  dest="verbose",
                  help="verbose output")
    """
    op.add_option("-p", "--page", type="int",
                  action="store", dest="page", default=0,
                  help="page number")
    op.add_option("-r", "--rpp", type="int",
                  action="store", dest="rpp", default=1000,
                  help="results per page")
    """
    op.add_option("-s",
                  "--status",
                  action="store",
                  dest="status",
                  help="query on status ['up'|'down'|'error']")
    add_json_option(op)

    (options, args) = op.parse_args(args)
    if len(args) != 1:
        op.error('expecting 1 argument')

    configFile = _open_config(args[0])

    query = {}
    if options.status:
        query['status'] = options.status

    # NOTE RESOURCE NOT SUPPORTING PAGING
    #pages = get_paging(configFile, SECTION, options, **query)
    #data = load_pages_json(pages)
    page = get_page(configFile, SECTION, **query)
    data = json.loads(page)
    if options.json:
        func = _print_as_json
    if func:
        func(data)
    return data
Exemple #4
0
def main_list(args=None, func=_print_numbered_lines):
    """Prints human readable listing of all session GUIDs.
    """
    op = optparse.OptionParser(usage="USAGE: %prog [options] CONFIG_FILE",
                               description=main_list.__doc__)

    add_options(op)
    add_json_option(op)
    (options, args) = op.parse_args(args)
    try:
        configFile = _open_config(*args)
    except Exception as ex:
        op.error(ex)

    if options.json:
        func = _print_as_json

    query = {}
    pages = get_paging(configFile, SECTION, options, **query)
    data = load_pages_json(pages)
    if func:
        func(data)
    return data