Beispiel #1
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])
            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 = fileoperations.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
Beispiel #2
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])
            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 = fileoperations.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
Beispiel #3
0
def plugins_base_get():
    controllers = handler.list('controller')
    plugins = []

    for c in controllers:
        is_base_scan = c.__name__.lower() == 'scan'
        if issubclass(c, BasePlugin) and not is_base_scan:
            plugins.append(c)

    return plugins
def plugins_get():
    controllers = handler.list('controller')
    plugins = filter(lambda c: issubclass(c, BasePlugin), controllers)

    return_plugins = []
    for p in plugins:
        plugin = Plugin(p)
        return_plugins.append(plugin)

    return return_plugins
Beispiel #5
0
def plugins_get():
    controllers = handler.list('controller')
    plugins = filter(lambda c: issubclass(c, BasePlugin), controllers)

    return_plugins = []
    for p in plugins:
        plugin = Plugin(p)
        return_plugins.append(plugin)

    return return_plugins
Beispiel #6
0
 def test_handler_list_bogus_type(self):
     self.app.setup()
     handler_list = handler.list('bogus')
Beispiel #7
0
 def test_handler_list(self):
     self.app.setup()
     handler_list = handler.list('config')
     res = ConfigParserConfigHandler in handler_list
     self.ok(res)
Beispiel #8
0
def plugins_base_get():
    controllers = handler.list('controller')
    plugins = [c for c in controllers if issubclass(c, BasePlugin)]

    return plugins