Ejemplo n.º 1
0
def set_profile(profile):
    if profile:
        aws.set_profile_override(profile)
    else:
        profile = commonops.get_default_profile()
        if profile:
            aws.set_profile(profile)
Ejemplo n.º 2
0
    def __init__(self):
        args = self._parse_args()

        # environment_name may be None
        self.environment_name = args.environment_name or get_current_branch_environment(
        )
        self.profile = self._raise_if_none(
            args.profile,
            get_default_profile(),
            "Please specify a specific profile in the command or eb configuration.",
        )
        self.region = self._raise_if_none(
            args.region,
            get_default_region(),
            "Please specify a specific region in the command or eb configuration.",
        )
Ejemplo n.º 3
0
    def default(self):
        """
        Creates a space separated list of possible completions.
        We actually do not need to calculate the completions. We can simply
        just generate a list of ALL possibilities, and then the bash completer
         module is smart enough to filter out the ones that don't match.

         Results must be printed through stdin for the completer module
         to read then.
        """

        commands = self.app.pargs.cmplt.strip('"')

        # Get commands, filter out last one
        commands = commands.split(' ')
        word_so_far = commands[-1]
        commands = commands[0:-1]
        commands = list(filter(lambda x: len(x) > 0, commands))

        #Get the list of controllers
        self.controllers = handler.list('controller')
        self._filter_controllers()

        ctrlr = self._get_desired_controller(commands)

        if not ctrlr:
            return  # command entered so far is invalid, we dont need to
            ##   worry about completion

        if word_so_far.startswith('--'):
            # Get all base option flags
            self.complete_options(ctrlr)
        else:
            if ctrlr == self.base_controller:
                # Get standard command list
                io.echo(*[
                    c.Meta.label for c in self.controllers
                    if not hasattr(c.Meta, 'stacked_type')
                ])
            else:
                # A command has been provided. Complete at a deeper level

                ctrlr = ctrlr()  # Instantiate so we can read all arguments

                if not hasattr(ctrlr, 'complete_command'):
                    return  # Controller does not support completion

                try:
                    #Set up aws profile just in case we need to make a service call
                    profile = commonops.get_default_profile()
                    if profile:
                        aws.set_profile(profile)
                    ctrlr.complete_command(commands)
                except:
                    #We want to swallow ALL exceptions. We can
                    ## not print any output when trying to tab-complete
                    ## because any output gets passed to the user as
                    ## completion candidates
                    ### Exceptions here are normally thrown because the service
                    ### can not be contacted for things such as environment
                    ### list and solution stack list. Typically, credentials
                    ### are not set up yet
                    pass
Ejemplo n.º 4
0
def get_profile():
    if _profile is not None:
        return _profile
    from ebcli.operations import commonops
    return commonops.get_default_profile(require_default=True)