def __init__(self, info_file): log.info("AddonInfo(%s) initializing.." , '/'.join(info_file.split('/')[-3:])) pars = parser.XBMCAddonXMLParser(info_file) addon_dict = pars.parse() self.id = addon_dict['id'] self.name = addon_dict['name'] self.version = addon_dict['version'] self.author = addon_dict['author'] self.type = addon_dict['type'] self.broken = addon_dict['broken'] self.path = os.path.dirname(info_file) self.library = addon_dict['library'] self.script = addon_dict['script'] self.tmp_path = config.plugins.archivCZSK.tmpPath.value self.data_path = os.path.join(config.plugins.archivCZSK.dataPath.getValue(), self.id) self.profile = self.data_path # create data_path(profile folder) util.make_path(self.data_path) if settings.LANGUAGE_SETTINGS_ID in addon_dict['description']: self.description = addon_dict['description'][settings.LANGUAGE_SETTINGS_ID] elif settings.LANGUAGE_SETTINGS_ID == 'sk' and 'cs' in addon_dict['description']: self.description = addon_dict['description']['cs'] else: if not 'en' in addon_dict['description']: self.description = u'' else: self.description = addon_dict['description']['en'] self.requires = addon_dict['requires'] self.image = os.path.join(self.path, 'icon.png') #changelog changelog_path = None if os.path.isfile(os.path.join(self.path, 'changelog.txt')): changelog_path = os.path.join(self.path, 'changelog.txt') elif os.path.isfile(os.path.join(self.path, 'Changelog.txt')): changelog_path = os.path.join(self.path, 'Changelog.txt') else: changelog_path = None if changelog_path is not None: with open(changelog_path, 'r') as f: text = f.read() try: self.changelog = text.decode('windows-1250') except Exception: log.error('%s c[C]angleog.txt cannot be decoded', self) self.changelog = u'' pass else: log.error('%s c[C]hangelog.txt file is missing', self) self.changelog = u''
def __init__(self, config_file): log.debug("initializing repository from %s", config_file) pars = parser.XBMCAddonXMLParser(config_file) repo_dict = pars.parse() self.id = repo_dict['id'] self.name = repo_dict['name'] self.author = repo_dict['author'] self.version = repo_dict['version'] self.description = repo_dict['description'] # every repository should have its update xml, to check versions and update/download addons self.update_xml_url = repo_dict['repo_addons_url'] self.update_datadir_url = repo_dict['repo_datadir_url'] self.path = os.path.dirname(config_file) self.addons_path = self.path #os.path.join(self.path, "addons") # addon.xml which describes addon self.addon_xml_relpath = 'addon.xml' # icon for addon size 256x256 self.addon_icon_relpath = 'icon.png' self.addon_resources_relpath = 'resources' # default language,settings and libraries path of addon self.addon_languages_relpath = self.addon_resources_relpath + '/language' self.addon_settings_relpath = self.addon_resources_relpath + '/settings.xml' self.addon_libraries_relpath = self.addon_resources_relpath + '/lib' self._addons = {} #create updater for repository self._updater = updater.Updater( self, os.path.join(config.plugins.archivCZSK.tmpPath.value, self.id)) # load installed addons in repository for addon_dir in os.listdir(self.addons_path): addon_path = os.path.join(self.addons_path, addon_dir) if os.path.isfile(addon_path): continue addon_info = AddonInfo( os.path.join(addon_path, self.addon_xml_relpath)) if addon_info.type not in Repository.SUPPORTED_ADDONS: raise Exception( "%s '%s' addon not in supported type of addons %s " % (self, addon_info.type, Repository.SUPPORTED_ADDONS)) if addon_info.type == 'video': try: tmp = os.path.join(addon_path, addon_info.script) if not os.path.isfile(tmp): raise Exception( "Invalid addon %s. Script file missing %s" % (addon_info.name, tmp)) addon = VideoAddon(addon_info, self) except Exception: traceback.print_exc() log.logError( "Load video addon %s failed, skipping...\n%s" % (addon_dir, traceback.format_exc())) #log.error("%s cannot load video addon %s, skipping.." , self, addon_dir) continue else: archivczsk.ArchivCZSK.add_addon(addon) self.add_addon(addon) elif addon_info.type == 'tools': # load tools addons try: tools = ToolsAddon(addon_info, self) except Exception: traceback.print_exc() log.error("%s cannot load tools addon %s, skipping..", self, addon_dir) continue else: archivczsk.ArchivCZSK.add_addon(tools) self.add_addon(tools) log.debug("%s successfully loaded", self)