Python npyscreen.FormBaseNew() Examples

The following are 2 code examples of npyscreen.FormBaseNew(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module npyscreen , or try the search function .
Example #1
Source File: services.py    From vent with Apache License 2.0 6 votes vote down vote up
def create(self):
        """ Override method for creating FormBaseNew form """
        self.add_handlers({'^T': self.quit, '^Q': self.quit})
        self.services_tft = self.add(npyscreen.TitleFixedText,
                                     name='No services running.',
                                     value='')
        services = Services(self.core, external=self.external)
        if services:
            self.services_tft.hidden = True
            for service in services:
                value = ''
                for val in service[1]:
                    value += val+', '
                self.add(npyscreen.TitleFixedText,
                         name=service[0],
                         value=value[:-2]) 
Example #2
Source File: inventory.py    From vent with Apache License 2.0 4 votes vote down vote up
def create(self):
        """ Override method for creating FormBaseNew form """
        self.add_handlers({'^T': self.quit, '^Q': self.quit,
                           '^V': self.toggle_view})
        self.add(npyscreen.TitleFixedText, name=self.action['title'], value='')
        response = self.action['api_action'].inventory(choices=['repos',
                                                                'tools',
                                                                'images',
                                                                'built',
                                                                'running'])
        if response[0]:
            inventory = response[1]
            if len(inventory['repos']) == 0:
                value = 'No tools were found.\n'
            else:
                value = 'Tools for all groups found:\n'
            tools = None
            if inventory['tools']:
                tools = inventory['tools']

            for repo in inventory['repos']:
                s_value = ''
                repo_name = repo.rsplit('/', 2)[1:]
                if len(repo_name) == 1:
                    repo_name = repo.split('/')
                if tools:
                    p_value = '\n  Plugin: ' + repo + '\n'
                    for tool in tools:
                        t_name = tool.split(':')
                        if (t_name[0] == repo_name[0] and
                                t_name[1] == repo_name[1]):
                            s_value += '    ' + tools[tool] + '\n      Built: '
                            s_value += inventory['built'][tool] + '\n'
                            s_value += '      Image name: '
                            s_value += inventory['images'][tool] + '\n'
                            s_value += '      Status: '
                            s_value += inventory['running'][tool] + '\n'
                if s_value:
                    value += p_value + s_value
        else:
            value = 'There was an issue with ' + self.action['name']
            value += ' retrieval:\n' + str(response[1])
            value += '\nPlease see vent.log for more details.'
        self.all_tools = value.split('\n')
        self.display_val = self.add(npyscreen.Pager, values=value.split('\n'))