示例#1
0
    def _scan_for_addons(self):
        """
        scan directories and load the addons
        :return: void ( sets class level dict with all the found addons )
        :raises: ImportError
        """
        possible_addons = self._search_for_addons()

        if len(possible_addons) > 0:
            for addon_file in possible_addons:
                addon_name, ext = AddonHelper.get_basename_and_ext(addon_file)

                if not self.ignore_addon_id and not addon_name.endswith(
                        self.addon_id):
                    self.log(
                        ">> Not loading '{0}' as file name does not end with '{0}'"
                        .format(addon_file, self.addon_id))
                    continue

                self.log("> Addon file '{0}' found...".format(addon_file))

                addon_info = AddonHelper.parse_info_file(addon_file)
                compatible_platforms = addon_info.get('os')

                if compatible_platforms is not None:
                    if AddonHelper.is_compatible_for_current_platform(
                            self.current_platform, compatible_platforms):
                        # Add in scanned_addons
                        self._update_scanned_addon_list(
                            addon_name, addon_file, addon_info)
                        self._load_module_from_source(addon_name, addon_file,
                                                      self.lazy_load)
                    else:
                        self.log(
                            ">>> Addon '{0}' not compatible with current '{1}' platform."
                            "supported platforms by this addon '{2}'".format(
                                addon_name, self.current_platform,
                                ', '.join(compatible_platforms)), "info")
                else:
                    # Add in scanned_addons
                    self._update_scanned_addon_list(addon_name, addon_file,
                                                    addon_info)
                    self._load_module_from_source(addon_name, addon_file,
                                                  self.lazy_load)
        else:
            self.log("No addons found", "error")
    def test_get_basename_and_ext(self):
        # addon_helper = AddonHelper()
        # self.assertEqual(expected, addon_helper.get_basename_and_ext())
        """
        test to check if works on both platforms...
        """
        test_file_path, file_name, file_ext = ('','','')
        
        if sys.platform.startswith('win'):
            test_file_path, file_name, file_ext = (r'c:\test\modules\TestAddon.py','TestAddon','py')
        else:
            test_file_path, file_name, file_ext = (r'/tmp/test/modules/TestAddonInfo.info','TestAddonInfo','info')

        name, ext = AddonHelper.get_basename_and_ext(test_file_path)

        self.assertEqual(file_name, name)
        self.assertEqual(file_ext, ext)        
示例#3
0
    def test_get_basename_and_ext(self):
        # addon_helper = AddonHelper()
        # self.assertEqual(expected, addon_helper.get_basename_and_ext())
        """
        test to check if works on both platforms...
        """
        test_file_path, file_name, file_ext = ('', '', '')

        if sys.platform.startswith('win'):
            test_file_path, file_name, file_ext = (
                r'c:\test\modules\TestAddon.py', 'TestAddon', 'py')
        else:
            test_file_path, file_name, file_ext = (
                r'/tmp/test/modules/TestAddonInfo.info', 'TestAddonInfo',
                'info')

        name, ext = AddonHelper.get_basename_and_ext(test_file_path)

        self.assertEqual(file_name, name)
        self.assertEqual(file_ext, ext)
示例#4
0
    def _scan_for_addons(self):
        """
        scan directories and load the addons
        :return: void ( sets class level dict with all the found addons )
        :raises: ImportError
        """
        possible_addons = self._search_for_addons()

        if len(possible_addons) > 0:
            for addon_file in possible_addons:
                addon_name, ext = AddonHelper.get_basename_and_ext(addon_file)

                if not self.ignore_addon_id and not addon_name.endswith(self.addon_id):
                    self.log(">> Not loading '{0}' as file name does not end with '{0}'".format(addon_file,
                                                                                                self.addon_id))
                    continue

                self.scanned_addons[addon_name] = {'FILE': addon_file, 'META': dict(), 'MODULE': None}
                self._load_module_from_source(addon_name, addon_file)
                self.log("> Addon file '{0}' found...".format(addon_file))
        else:
            self.log("No addons found", "error")
示例#5
0
    def _scan_for_addons(self):
        """
        scan directories and load the addons
        :return: void ( sets class level dict with all the found addons )
        :raises: ImportError
        """
        possible_addons = self._search_for_addons()

        if len(possible_addons) > 0:
            for addon_file in possible_addons:
                addon_name, ext = AddonHelper.get_basename_and_ext(addon_file)

                if not self.ignore_addon_id and not addon_name.endswith(self.addon_id):
                    self.log(">> Not loading '{0}' as file name does not end with '{0}'".format(addon_file,
                                                                                                self.addon_id))
                    continue

                self.log("> Addon file '{0}' found...".format(addon_file))

                addon_info = AddonHelper.parse_info_file(addon_file)
                compatible_platforms = addon_info.get('os')

                if compatible_platforms is not None:
                    if AddonHelper.is_compatible_for_current_platform(self.current_platform, compatible_platforms):
                        # Add in scanned_addons
                        self._update_scanned_addon_list(addon_name, addon_file, addon_info)
                        self._load_module_from_source(addon_name, addon_file, self.lazy_load)
                    else:
                        self.log(">>> Addon '{0}' not compatible with current '{1}' platform."
                                 "supported platforms by this addon '{2}'".
                                 format(addon_name, self.current_platform, ', '.join(compatible_platforms)), "info")
                else:
                    # Add in scanned_addons
                    self._update_scanned_addon_list(addon_name, addon_file, addon_info)
                    self._load_module_from_source(addon_name, addon_file, self.lazy_load)
        else:
            self.log("No addons found", "error")