Ejemplo n.º 1
0
    def collect(self):
        commands = import_string(self._location)
        builtin_command_dir = os.path.abspath(
                os.path.dirname(commands.__file__))

        import_template = '%s.%s' % (commands.__name__, '%s')

        builtin_command_files = os.listdir(builtin_command_dir)

        collected_commands = []
        collected_hooks = []

        for filename in builtin_command_files:
            if filename.endswith('.py') and not filename == '__init__.py':
                # Load the file. That's all that should be necessary
                module_name = filename[:-3]
                import_path_string = import_template % module_name
                try:
                    command_module = import_string(import_path_string)
                except ImportError:
                    logger.exception('Failed to collect builtin command '
                        'module "%s"' % filename)
                else:
                    command_list, hook_list = self.collect_in_module(
                            command_module)
                    collected_commands.extend(command_list)
                    collected_hooks.extend(hook_list)
        return collected_commands, collected_hooks
Ejemplo n.º 2
0
    def collect(self):
        commands = import_string(self._location)
        builtin_command_dir = os.path.abspath(
            os.path.dirname(commands.__file__))

        import_template = '%s.%s' % (commands.__name__, '%s')

        builtin_command_files = os.listdir(builtin_command_dir)

        collected_commands = []
        collected_hooks = []

        for filename in builtin_command_files:
            if filename.endswith('.py') and not filename == '__init__.py':
                # Load the file. That's all that should be necessary
                module_name = filename[:-3]
                import_path_string = import_template % module_name
                try:
                    command_module = import_string(import_path_string)
                except ImportError:
                    logger.exception('Failed to collect builtin command '
                                     'module "%s"' % filename)
                else:
                    command_list, hook_list = self.collect_in_module(
                        command_module)
                    collected_commands.extend(command_list)
                    collected_hooks.extend(hook_list)
        return collected_commands, collected_hooks
Ejemplo n.º 3
0
    def _load_builtin_commands(self):
        from virtstrap import commands
        builtin_command_dir = os.path.abspath(os.path.dirname(commands.__file__))

        import_template = '%s.%s' % (commands.__name__, '%s')

        builtin_command_files = os.listdir(builtin_command_dir)

        for filename in builtin_command_files:
            if filename.endswith('.py'):
                # Load the file. That's all that should be necessary
                module_name = filename[:-3]
                import_string = import_template % module_name
                try:
                    __import__(import_string)
                except ImportError:
                    logger.exception('Failed to load builtin command '
                        'module "%s"' % filename)
Ejemplo n.º 4
0
    def _load_builtin_commands(self):
        from virtstrap import commands
        builtin_command_dir = os.path.abspath(
            os.path.dirname(commands.__file__))

        import_template = '%s.%s' % (commands.__name__, '%s')

        builtin_command_files = os.listdir(builtin_command_dir)

        for filename in builtin_command_files:
            if filename.endswith('.py'):
                # Load the file. That's all that should be necessary
                module_name = filename[:-3]
                import_string = import_template % module_name
                try:
                    __import__(import_string)
                except ImportError:
                    logger.exception('Failed to load builtin command '
                                     'module "%s"' % filename)