示例#1
0
    def _load_own_config(self):
        """
        load AddonLoader config file or if not found set to default
        :return: config
        :rtype: dict
        """
        config_file = os.path.join(self.init_dir, 'addon-loader.info')
        self.log("Trying to read addonpy config for this project from '{0}'".format(config_file))
        addon_conf = AddonHelper.parse_info_file(config_file)

        if addon_conf is None:
            self.log("addon-loader.info file not found/not proper, loading pre-configured addon config")
            addon_conf = dict(required_functions=['start', 'stop', 'execute', '__addon__'],
                              addon_places=[os.path.abspath(os.curdir)],
                              recursive='False',
                              verbose='False')

            self.active_config = addon_conf
            return

        addon_places = addon_conf.get('addon_places')

        if addon_places is not None:
            for dir_name in addon_conf.get('addon_places'):
                _abs_temp_path = self._get_abspath(dir_name, True)
                if os.path.isdir(_abs_temp_path):
                    self.addon_dirs.append(_abs_temp_path)
        else:
            self.addon_dirs.append(os.path.abspath(os.path.curdir))

        addon_conf['addon_places'] = self.addon_dirs
        self.active_config = addon_conf
示例#2
0
def parse_config():

    if options.conf == "Default":
        return CONF_TEMPLATE

    try:
        config = helper.parse_info_file(options.conf)
    except ValueError:
        print("Error: Invalid config file '{0}' please make sure config is valid JSON".format(options.conf))
        sys.exit(9)

    return config
示例#3
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")
示例#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.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")