<s> """<STR_LIT>""" <EOL> import logging <EOL> import sys <EOL> from mistralclient . api import client <EOL> import mistralclient . commands . v2 . action_executions <EOL> import mistralclient . commands . v2 . actions <EOL> import mistralclient . commands . v2 . cron_triggers <EOL> import mistralclient . commands . v2 . environments <EOL> import mistralclient . commands . v2 . executions <EOL> import mistralclient . commands . v2 . members <EOL> import mistralclient . commands . v2 . services <EOL> import mistralclient . commands . v2 . tasks <EOL> import mistralclient . commands . v2 . workbooks <EOL> import mistralclient . commands . v2 . workflows <EOL> from mistralclient . openstack . common import cliutils as c <EOL> from cliff import app <EOL> from cliff import command <EOL> from cliff import commandmanager <EOL> import argparse <EOL> LOG = logging . getLogger ( __name__ ) <EOL> class OpenStackHelpFormatter ( argparse . HelpFormatter ) : <EOL> def __init__ ( self , prog , indent_increment = <NUM_LIT:2> , max_help_position = <NUM_LIT:32> , <EOL> width = None ) : <EOL> super ( OpenStackHelpFormatter , self ) . __init__ ( <EOL> prog , <EOL> indent_increment , <EOL> max_help_position , <EOL> width <EOL> ) <EOL> def start_section ( self , heading ) : <EOL> heading = '<STR_LIT>' % ( heading [ <NUM_LIT:0> ] . upper ( ) , heading [ <NUM_LIT:1> : ] ) <EOL> super ( OpenStackHelpFormatter , self ) . start_section ( heading ) <EOL> class HelpAction ( argparse . Action ) : <EOL> """<STR_LIT>""" <EOL> def __call__ ( self , parser , namespace , values , option_string = None ) : <EOL> outputs = [ ] <EOL> max_len = <NUM_LIT:0> <EOL> app = self . default <EOL> parser . print_help ( app . stdout ) <EOL> app . stdout . write ( '<STR_LIT>' ) <EOL> for name , ep in sorted ( app . command_manager ) : <EOL> factory = ep . load ( ) <EOL> cmd = factory ( self , None ) <EOL> one_liner = cmd . get_description ( ) . split ( '<STR_LIT:\n>' ) [ <NUM_LIT:0> ] <EOL> outputs . append ( ( name , one_liner ) ) <EOL> max_len = max ( len ( name ) , max_len ) <EOL> for ( name , one_liner ) in outputs : <EOL> app . stdout . write ( '<STR_LIT>' % ( name . ljust ( max_len ) , one_liner ) ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> class BashCompletionCommand ( command . Command ) : <EOL> """<STR_LIT>""" <EOL> def take_action ( self , parsed_args ) : <EOL> commands = set ( ) <EOL> options = set ( ) <EOL> for option , _action in self . app . parser . _option_string_actions . items ( ) : <EOL> options . add ( option ) <EOL> for command_name , _cmd in self . app . command_manager : <EOL> commands . add ( command_name ) <EOL> print ( '<STR_LIT:U+0020>' . join ( commands | options ) ) <EOL> class MistralShell ( app . App ) : <EOL> def __init__ ( self ) : <EOL> super ( MistralShell , self ) . __init__ ( <EOL> description = __doc__ . strip ( ) , <EOL> version = mistralclient . __version__ , <EOL> command_manager = commandmanager . CommandManager ( '<STR_LIT>' ) , <EOL> ) <EOL> self . _set_shell_commands ( self . _get_commands_v2 ( ) ) <EOL> def configure_logging ( self ) : <EOL> log_lvl = logging . DEBUG if self . options . debug else logging . WARNING <EOL> logging . basicConfig ( <EOL> format = "<STR_LIT>" , <EOL> level = log_lvl <EOL> ) <EOL> logging . getLogger ( '<STR_LIT>' ) . setLevel ( logging . WARNING ) <EOL> if self . options . verbose_level <= <NUM_LIT:1> : <EOL> logging . getLogger ( '<STR_LIT>' ) . setLevel ( logging . WARNING ) <EOL> def build_option_parser ( self , description , version , <EOL> argparse_kwargs = None ) : <EOL> """<STR_LIT>""" <EOL> argparse_kwargs = argparse_kwargs or { } <EOL> parser = argparse . ArgumentParser ( <EOL> description = description , <EOL> add_help = False , <EOL> formatter_class = OpenStackHelpFormatter , <EOL> ** argparse_kwargs <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:version>' , <EOL> version = '<STR_LIT>' . format ( version ) , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> action = '<STR_LIT:count>' , <EOL> dest = '<STR_LIT>' , <EOL> default = self . DEFAULT_VERBOSE_LEVEL , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> default = None , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> action = '<STR_LIT>' , <EOL> dest = '<STR_LIT>' , <EOL> const = <NUM_LIT:0> , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> action = HelpAction , <EOL> nargs = <NUM_LIT:0> , <EOL> default = self , <EOL> help = "<STR_LIT>" , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> default = False , <EOL> action = '<STR_LIT:store_true>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> dest = '<STR_LIT>' , <EOL> default = c . env ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> dest = '<STR_LIT>' , <EOL> default = c . env ( '<STR_LIT>' , default = '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> dest = '<STR_LIT>' , <EOL> default = c . env ( '<STR_LIT>' , default = '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> dest = '<STR_LIT>' , <EOL> default = c . env ( '<STR_LIT>' , default = '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> dest = '<STR_LIT:username>' , <EOL> default = c . env ( '<STR_LIT>' , default = '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> dest = '<STR_LIT:password>' , <EOL> default = c . env ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> dest = '<STR_LIT>' , <EOL> default = c . env ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> dest = '<STR_LIT>' , <EOL> default = c . env ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> dest = '<STR_LIT>' , <EOL> default = c . env ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> dest = '<STR_LIT>' , <EOL> default = c . env ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store>' , <EOL> dest = '<STR_LIT>' , <EOL> default = c . env ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , <EOL> dest = '<STR_LIT>' , <EOL> default = c . env ( '<STR_LIT>' , default = False ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> return parser <EOL> def initialize_app ( self , argv ) : <EOL> self . _clear_shell_commands ( ) <EOL> ver = client . determine_client_version ( self . options . mistral_version ) <EOL> self . _set_shell_commands ( self . _get_commands ( ver ) ) <EOL> do_help = ( '<STR_LIT>' in argv ) or ( '<STR_LIT>' in argv ) or not argv <EOL> if not self . options . auth_url : <EOL> if self . options . password or self . options . token : <EOL> self . options . auth_url = '<STR_LIT>' <EOL> if do_help or ( '<STR_LIT>' in argv ) : <EOL> self . options . auth_url = None <EOL> self . client = client . client ( <EOL> mistral_url = self . options . mistral_url , <EOL> username = self . options . username , <EOL> api_key = self . options . password , <EOL> project_name = self . options . tenant_name , <EOL> auth_url = self . options . auth_url , <EOL> project_id = self . options . tenant_id , <EOL> endpoint_type = self . options . endpoint_type , <EOL> service_type = self . options . service_type , <EOL> auth_token = self . options . token , <EOL> cacert = self . options . cacert , <EOL> insecure = self . options . insecure <EOL> ) <EOL> ClientManager = type ( <EOL> '<STR_LIT>' , <EOL> ( object , ) , <EOL> dict ( workflow_engine = self . client ) <EOL> ) <EOL> self . client_manager = ClientManager ( ) <EOL> def _set_shell_commands ( self , cmds_dict ) : <EOL> for k , v in cmds_dict . items ( ) : <EOL> self . command_manager . add_command ( k , v ) <EOL> def _clear_shell_commands ( self ) : <EOL> exclude_cmds = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> cmds = self . command_manager . commands . copy ( ) <EOL> for k , v in cmds . items ( ) : <EOL> if k not in exclude_cmds : <EOL> self . command_manager . commands . pop ( k ) <EOL> def _get_commands ( self , version ) : <EOL> if version == <NUM_LIT:2> : <EOL> return self . _get_commands_v2 ( ) <EOL> return { } <EOL> @ staticmethod <EOL> def _get_commands_v2 ( ) : <EOL> return { <EOL> '<STR_LIT>' : BashCompletionCommand , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . workbooks . List , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . workbooks . Get , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . workbooks . Create , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . workbooks . Delete , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . workbooks . Update , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . workbooks . GetDefinition , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . workbooks . Validate , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . workflows . List , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . workflows . Get , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . workflows . Create , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . workflows . Delete , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . workflows . Update , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . workflows . GetDefinition , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . workflows . Validate , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . environments . Create , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . environments . Delete , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . environments . Update , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . environments . List , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . environments . Get , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . action_executions . Create , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . action_executions . List , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . action_executions . Get , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . action_executions . GetInput , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . action_executions . GetOutput , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . action_executions . Update , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . action_executions . Delete , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . executions . Create , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . executions . Delete , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . executions . Update , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . executions . List , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . executions . Get , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . executions . GetInput , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . executions . GetOutput , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . tasks . List , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . tasks . Get , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . tasks . GetPublished , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . tasks . GetResult , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . tasks . Rerun , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . actions . List , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . actions . Get , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . actions . Create , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . actions . Delete , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . actions . Update , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . actions . GetDefinition , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . cron_triggers . List , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . cron_triggers . Get , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . cron_triggers . Create , <EOL> '<STR_LIT>' : <EOL> mistralclient . commands . v2 . cron_triggers . Delete , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . services . List , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . members . Create , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . members . Delete , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . members . Update , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . members . List , <EOL> '<STR_LIT>' : mistralclient . commands . v2 . members . Get , <EOL> } <EOL> def main ( argv = sys . argv [ <NUM_LIT:1> : ] ) : <EOL> return MistralShell ( ) . run ( argv ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> sys . exit ( main ( sys . argv [ <NUM_LIT:1> : ] ) ) </s>
