def print_block_bgp(block_dicts): """ Formatted printing of a list of blocks. This expects a list of dictionaries of block data, such as the output from the system component's get_blocks call. """ for block in block_dicts: header_list = [] value_list = [] for key, value in block.iteritems(): if key in ['node_cards', 'nodes']: if block['size'] > 32 and key == 'nodes': continue else: header_list.append(key) value_list.append(' '.join([v['id'] for v in value])) else: header_list.append(key) value_list.append(value) client_utils.print_vertical([header_list, value_list]) return
def print_block_bgp(block_dicts): """ Formatted printing of a list of blocks. This expects a list of dictionaries of block data, such as the output from the system component's get_blocks call. """ for block in block_dicts: header_list = [] value_list = [] for key, value in block.iteritems(): if key in ['node_cards','nodes']: if block['size'] > 32 and key == 'nodes': continue else: header_list.append(key) value_list.append(' '.join([v['id'] for v in value])) else: header_list.append(key) value_list.append(value) client_utils.print_vertical([header_list, value_list]) return
def process_the_output(output, parser, hinfo): """ process the qstat output """ fields = ['score'] if parser.options.sort == None else [ f.lower() for f in parser.options.sort ] lower_case_header = [str(h).lower() for h in hinfo.header] idxes = [] for f in fields: try: idx = lower_case_header.index(f) idxes.append(idx) except: pass if not idxes: idxes.append(0) def _my_cmp(left, right): for idx in idxes: try: val = cmp(float(left[idx]), float(right[idx])) except: val = cmp(left[idx], right[idx]) if val == 0: continue else: return val return 0 output.sort(_my_cmp) if parser.options.reverse != None: output.reverse() if "short_state" in lower_case_header: idx = lower_case_header.index("short_state") hinfo.header[idx] = "S" if "score" in lower_case_header: idx = lower_case_header.index("score") for line in output: line[idx] = human_format(float(line[idx])) if parser.options.long != None: client_utils.print_vertical( [tuple(x) for x in [hinfo.header] + output]) else: client_utils.print_tabular([tuple(x) for x in [hinfo.header] + output])
def process_the_output(output,parser,hinfo): """ process the qstat output """ fields = ['score'] if parser.options.sort == None else [f.lower() for f in parser.options.sort] lower_case_header = [str(h).lower() for h in hinfo.header] idxes = [] for f in fields: try: idx = lower_case_header.index(f) idxes.append(idx) except: pass if not idxes: idxes.append(0) def _my_cmp(left, right): for idx in idxes: try: val = cmp(float(left[idx]), float(right[idx])) except: val = cmp(left[idx], right[idx]) if val == 0: continue else: return val return 0 output.sort(_my_cmp) if parser.options.reverse != None: output.reverse() if "short_state" in lower_case_header: idx = lower_case_header.index("short_state") hinfo.header[idx] = "S" if "score" in lower_case_header: idx = lower_case_header.index("score") for line in output: line[idx] = human_format(float(line[idx])) if parser.options.long != None: client_utils.print_vertical([tuple(x) for x in [hinfo.header] + output]) else: client_utils.print_tabular([tuple(x) for x in [hinfo.header] + output])
def print_block_bgq(block_dicts): """Formatted printing of a list of blocks. This expects a list of dictionaries of block data, such as the output from the system component's get_blocks call. """ for block in block_dicts: header_list = [] value_list = [] header_list.append('Name') value_list.append(block['name']) for key, value in block.iteritems(): if key in [ 'passthrough_node_card_list', 'node_card_list', 'node_list' ]: if block['size'] >= 512 and key == 'node_card_list': continue if block['size'] >= 128 and key == 'node_list': continue header_list.append(key) value_list.append(' '.join([v['name'] for v in value])) elif key == 'wire_list': header_list.append(key) value.sort() value_list.append(' '.join([v['id'] for v in value])) elif key in [ 'midplane_list', 'parents', 'children', 'passthrough_blocks', 'wiring_conflict_list', 'io_drawer_list', 'io_node_list' ]: header_list.append(key) value.sort() value_list.append(', '.join(value)) elif key == 'name': pass else: header_list.append(key) value_list.append(value) client_utils.print_vertical([header_list, value_list]) return
def print_block_bgq(block_dicts): """Formatted printing of a list of blocks. This expects a list of dictionaries of block data, such as the output from the system component's get_blocks call. """ for block in block_dicts: header_list = [] value_list = [] header_list.append('Name') value_list.append(block['name']) for key, value in block.iteritems(): if key in ['passthrough_node_card_list', 'node_card_list','node_list']: if block['size'] >= 512 and key == 'node_card_list': continue if block['size'] >= 128 and key == 'node_list': continue header_list.append(key) value_list.append(' '.join([v['name'] for v in value])) elif key == 'wire_list': header_list.append(key) value.sort() value_list.append(' '.join([v['id'] for v in value])) elif key in ['midplane_list', 'parents', 'children', 'passthrough_blocks', 'wiring_conflict_list', 'io_drawer_list', 'io_node_list']: header_list.append(key) value.sort() value_list.append(', '.join(value)) elif key == 'name': pass else: header_list.append(key) value_list.append(value) client_utils.print_vertical([header_list, value_list]) return
def print_io_block(io_block_dicts): '''print detailed information on a set of IO blocks.''' for block in io_block_dicts: header_list = block.keys() value_list = block.values() client_utils.print_vertical([header_list, value_list])