예제 #1
0
def main():
    """
    qstat main
    """
    # setup logging for client. The clients should call this before doing anything else.
    client_utils.setup_logging(logging.INFO)

    delim = ':'

    # list of callback with its arguments
    callbacks = [
        # <cb function>     <cb args (tuple) >
        (cb_debug, ()),
        (cb_split, (delim, ))
    ]

    # Get the version information
    opt_def = __doc__.replace('__revision__', __revision__)
    opt_def = opt_def.replace('__version__', __version__)

    parser = ArgParse(opt_def, callbacks)
    parser.parse_it()  # parse the command line

    # Get the header instance
    hinfo = client_utils.header_info(parser)

    # Get the queues for job ids
    queues = client_utils.component_call(QUEMGR, True, 'get_queues',
                                         ([{
                                             'name': '*',
                                             'state': '*'
                                         }], ))

    #  if Q option specified then get the info for the specified queues
    if parser.options.Q != None:

        output = get_output_for_queues(parser, hinfo)

    else:

        # build query from long_header (all fields) and fetch response
        output = get_output_for_jobs(parser, hinfo, queues)

    process_the_output(output, parser, hinfo)
예제 #2
0
def test_header4():
    """
    Test environment variable CQSTAT_HEADER_FULL 2
    """
    delim = ':'
    callbacks = [
        # <cb function>     <cb args (tuple) >
        ( cb_debug        , () ),
        ( cb_split        , (delim,) ) ]

    environ['QSTAT_HEADER_FULL'] = 'custom:qheader:full'
    parser = ArgParse(__doc__, callbacks)
    parser.parse_it(['-f']) # parse the command line
    h = header_info(parser)
    if h.header == ['custom','cqheader','full']:
        good = True
    else:
        good = False
    assert good, "Wrong value for header: %s" % str(h.header)
예제 #3
0
def test_header4():
    """
    Test environment variable CQSTAT_HEADER_FULL 2
    """
    delim = ':'
    callbacks = [
        # <cb function>     <cb args (tuple) >
        (cb_debug, ()),
        (cb_split, (delim, ))
    ]

    environ['QSTAT_HEADER_FULL'] = 'custom:qheader:full'
    parser = ArgParse(__doc__, callbacks)
    parser.parse_it(['-f'])  # parse the command line
    h = header_info(parser)
    if h.header == ['custom', 'cqheader', 'full']:
        good = True
    else:
        good = False
    assert good, "Wrong value for header: %s" % str(h.header)
예제 #4
0
파일: qstat.py 프로젝트: ido/cobalt
def main():
    """
    qstat main
    """
    # setup logging for client. The clients should call this before doing anything else.
    client_utils.setup_logging(logging.INFO)

    delim = ':'

    # list of callback with its arguments
    callbacks = [
        # <cb function>     <cb args (tuple) >
        ( cb_debug        , () ),
        ( cb_split        , (delim,) ) ]

    # Get the version information
    opt_def =  __doc__.replace('__revision__',__revision__)
    opt_def =  opt_def.replace('__version__',__version__)

    parser = ArgParse(opt_def,callbacks)
    parser.parse_it() # parse the command line

    # Get the header instance 
    hinfo = client_utils.header_info(parser)

    # Get the queues for job ids
    queues = client_utils.component_call(QUEMGR, True, 'get_queues', ([{'name':'*','state':'*'}],))

    #  if Q option specified then get the info for the specified queues 
    if parser.options.Q != None:

        output = get_output_for_queues(parser,hinfo)

    else:

        # build query from long_header (all fields) and fetch response        
        output = get_output_for_jobs(parser,hinfo,queues)

    process_the_output(output,parser,hinfo)