<s> from app . client . cluster_api_client import ClusterMasterAPIClient <EOL> from app . subcommands . subcommand import Subcommand <EOL> from app . util import log <EOL> from app . util . conf . configuration import Configuration <EOL> class ShutdownSubcommand ( Subcommand ) : <EOL> def run ( self , log_level , master_url , slave_ids = None , all_slaves = False , ** request_params ) : <EOL> log_level = log_level or Configuration [ '<STR_LIT>' ] <EOL> log . configure_logging ( log_level = log_level , simplified_console_logs = True ) <EOL> master_url = master_url or '<STR_LIT>' . format ( Configuration [ '<STR_LIT>' ] , Configuration [ '<STR_LIT:port>' ] ) <EOL> client = ClusterMasterAPIClient ( master_url ) <EOL> if all_slaves : <EOL> client . graceful_shutdown_all_slaves ( ) <EOL> elif slave_ids and len ( slave_ids ) > <NUM_LIT:0> : <EOL> client . graceful_shutdown_slaves_by_id ( slave_ids ) <EOL> else : <EOL> self . _logger . error ( '<STR_LIT>' ) <EOL> exit ( <NUM_LIT:1> ) </s>
