<s> from __future__ import absolute_import , print_function <EOL> import blessings <EOL> import prettytable <EOL> from . . import cli <EOL> from . . master import CURRENT as MASTER <EOL> try : <EOL> from collections import OrderedDict <EOL> except ImportError : <EOL> from ordereddict import OrderedDict <EOL> parser = cli . parser ( <EOL> description = "<STR_LIT>" <EOL> ) <EOL> parser . add_argument ( <EOL> "<STR_LIT>" , "<STR_LIT>" , action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" <EOL> ) <EOL> @ cli . init ( parser ) <EOL> def main ( args ) : <EOL> term = blessings . Terminal ( ) <EOL> table_generator = OrderedDict ( [ <EOL> ( "<STR_LIT>" , lambda x : x . id ) , <EOL> ( "<STR_LIT:name>" , lambda x : x . name ) , <EOL> ( "<STR_LIT:host>" , lambda x : x . hostname ) , <EOL> ( "<STR_LIT>" , lambda x : x . active ) , <EOL> ( "<STR_LIT>" , lambda x : x . task_count ) , <EOL> ( "<STR_LIT>" , lambda x : x . cpu_allocated ) , <EOL> ( "<STR_LIT>" , lambda x : x . mem_allocated ) , <EOL> ( "<STR_LIT>" , lambda x : x . disk_allocated ) , <EOL> ] ) <EOL> tb = prettytable . PrettyTable ( <EOL> [ x . upper ( ) for x in table_generator . keys ( ) ] , <EOL> border = False , <EOL> max_table_width = term . width , <EOL> hrules = prettytable . NONE , <EOL> vrules = prettytable . NONE , <EOL> left_padding_width = <NUM_LIT:0> , <EOL> right_padding_width = <NUM_LIT:1> <EOL> ) <EOL> def format_row ( framework ) : <EOL> return [ fn ( framework ) for fn in table_generator . values ( ) ] <EOL> for framework in MASTER . frameworks ( active_only = not args . inactive ) : <EOL> tb . add_row ( format_row ( framework ) ) <EOL> if tb . rowcount == <NUM_LIT:0> : <EOL> cli . header ( '<STR_LIT>' ) <EOL> else : <EOL> print ( tb ) </s>
