コード例 #1
0
ファイル: lmit_main.py プロジェクト: ienvyou/lmit
    def __init__(self):
        logger.info("Plugins Directory(location: %s)" % plugins_path)
        # Init the plugin list dict
        self._plugins = collections.defaultdict(dict)

        # Load plugins
        self.load_plugins(args=None) 
コード例 #2
0
ファイル: lmit_main.py プロジェクト: ienvyou/lmit
    def __init__(self):
        logger.info("Plugins Directory(location: %s)" % plugins_path)
        # Init the plugin list dict
        self._plugins = collections.defaultdict(dict)

        # Load plugins
        self.load_plugins(args=None)
コード例 #3
0
ファイル: lmit_main.py プロジェクト: ienvyou/lmit
    def load_plugins(self, args=None):
        """ Load all plugins in the 'plugins' directory."""
        header = "lmit_"
        for item in os.listdir(plugins_path):
            if item.startswith(header) and item.endswith(".py"):
                # Import the plugin
                plugin = __import__(os.path.basename(item)[:-3])
                plugin_name = os.path.basename(item)[len(header):-3].lower()

                self._plugins[plugin_name] = plugin.SubMenu(args=args)
        # Log plugin list
        logger.info("Available plugins list: {0}".format(self.getAllPlugins()))
コード例 #4
0
ファイル: lmit_main.py プロジェクト: ienvyou/lmit
    def load_plugins(self, args=None):
        """ Load all plugins in the 'plugins' directory."""
        header = "lmit_"
        for item in os.listdir(plugins_path):
            if item.startswith(header) and item.endswith(".py"):
                # Import the plugin
                plugin = __import__(os.path.basename(item)[:-3])
                plugin_name = os.path.basename(item)[len(header):-3].lower()

                self._plugins[plugin_name] = plugin.SubMenu(args=args)
        # Log plugin list
        logger.info("Available plugins list: {0}".format(self.getAllPlugins()))
コード例 #5
0
ファイル: lmit_menu.py プロジェクト: ienvyou/lmit
    def __catch_key(self):
        # Catch the pressed key
        self.pressedkey = self.get_key(self.term_window)

        # Actions
        if self.pressedkey == ord('\x1b') or self.pressedkey == ord('q'):
            # 'ESC'|'q' > Quit
            self.end()
            logger.info("Stop LMIT by q-key event")
            sys.exit(0)

        return self.pressedkey
コード例 #6
0
ファイル: __init__.py プロジェクト: ienvyou/lmit
def main():
    # Log LMIT and PSutil version
    logger.info('Start LMIT {0}'.format(__version__))
    logger.info('{0} {1} and PSutil {2} detected'.format(
        platform.python_implementation(), platform.python_version(),
        __psutil_version))

    # Share global var
    global core

    # Create the LMIT main instance
    core = LmitMain()

    # Catch the CTRL-C signal
    signal.signal(signal.SIGINT, __signal_handler)

    # Load Plug-In directory
    core.getAllPlugins()

    core.process()
コード例 #7
0
ファイル: __init__.py プロジェクト: ienvyou/lmit
def main():
    # Log LMIT and PSutil version
    logger.info('Start LMIT {0}'.format(__version__))
    logger.info('{0} {1} and PSutil {2} detected'.format(
        platform.python_implementation(),
        platform.python_version(),
        __psutil_version))

    # Share global var
    global core

    # Create the LMIT main instance
    core = LmitMain()

    # Catch the CTRL-C signal
    signal.signal(signal.SIGINT, __signal_handler)

    # Load Plug-In directory
    core.getAllPlugins()

    core.process()
コード例 #8
0
ファイル: lmit_menu.py プロジェクト: ienvyou/lmit
    def display(self):
        # Line index
        self.menu_line = 5
        self.menu_column = 5

        # Cursur index
        self.index = 0

        # Get the screen size
        screen_x = self.screen.getmaxyx()[1]
        screen_y = self.screen.getmaxyx()[0]

        logger.info('Screen size x: {0}, y: {1}'.format(screen_x, screen_y))

        mode = curses.A_REVERSE

        title = "Linux Management Interface Tool(LMIT)"

        title_x = screen_x / 2
        self.term_window.addstr(1, title_x - (len(title) / 2), title,
                                curses.A_BOLD)

        self.term_window.addstr(3, 2, self.menu_item['title'])

        items = self.menu_item['items']

        for item in items:
            #logger.info('menu name: {0}'.format(item['menu']))
            if self.index == self.position:
                mode = curses.A_REVERSE
            else:
                mode = curses.A_NORMAL

            self.term_window.addstr(self.menu_line + self.index,
                                    self.menu_column, item['menu'], mode)
            self.index = self.index + 1

        self.term_window.border(0)
        self.term_window.refresh()
コード例 #9
0
ファイル: lmit_menu.py プロジェクト: ienvyou/lmit
    def process(self):

        # Display first
        self.display()

        # Wait key
        exitkey = False

        while not exitkey:
            # Get key
            pressedkey = self.__catch_key()
            #logger.info('Current pressed key: {0}'.format(self.pressedkey))

            # Is it an exit key?
            exitkey = (self.pressedkey == ord('\x1b')
                       or self.pressedkey == ord('q'))
            if not exitkey and self.pressedkey > -1:
                # Pressed key is KEY_UP
                if self.pressedkey == 65:
                    logger.info('Key Up Event')
                    if self.position > 0:
                        self.position = self.position - 1
                # Pressed key is KEY_DOWN
                elif self.pressedkey == 66:
                    logger.info('Key Down Event')
                    if self.position < len(self.menu_item['items']) - 1:
                        self.position = self.position + 1
                # Pressed key is KEY_ENTER
                elif self.pressedkey == 10:
                    item = self.menu_item['items'][self.position]
                    logger.info('Enter Key Event - {0}'.format(item['menu']))
                    logger.info('Menu Key Name - {0}'.format(item['key']))

                    # Load plugin class from dictionary
                    """plugin = self._plugins[item['key']]
                    submenu = plugin.getMenuItem()
                    logger.info('SubMenu - {0}'.format(submenu))"""

                    # Call override method
                    plugin = self._plugins[item['key']]
                    plugin.process()

                # Redraw display
                self.display()

            # Wait 50ms
            curses.napms(50)
コード例 #10
0
ファイル: __init__.py プロジェクト: ienvyou/lmit
def end():
    """Stop LMIT."""
    logger.info("Stop LMIT(with CTRL-C)")

    # End
    sys.exit(0)
コード例 #11
0
ファイル: lmit_main.py プロジェクト: ienvyou/lmit
    def process(self):
        logger.info("LMIT Main Process is started")

        menu = LmitMenu(menu_item, self._plugins)
        menu.process()
コード例 #12
0
ファイル: __init__.py プロジェクト: ienvyou/lmit
def end():
    """Stop LMIT."""
    logger.info("Stop LMIT(with CTRL-C)")

    # End
    sys.exit(0)
コード例 #13
0
ファイル: lmit_main.py プロジェクト: ienvyou/lmit
 def process(self):
     logger.info("LMIT Main Process is started")
     
     menu = LmitMenu(menu_item, self._plugins)
     menu.process()