def update_addon(self, addon_entry): # Expected format: "mydomain.com/myaddon" or "mydomain.com/myaddon|subfolder [version_track]" addon_entry, *addon_version_track = addon_entry.split(' ') addon_url, *subfolder = addon_entry.split('|') addon_version_track = self.validate_addon_version_track( addon_version_track) site = site_handler.get_handler(addon_url, self.game_version, addon_version_track) try: addon_name = site.get_addon_name() except Exception as e: logger.exception(e) if subfolder: [subfolder] = subfolder addon_name = f"{addon_name}|{subfolder}" try: latest_version = site.get_latest_version() except SiteError as e: logger.exception(e) latest_version = AddonManager._UNAVAILABLE installed_version = self.get_installed_version(addon_name) if latest_version in [AddonManager._UNAVAILABLE, installed_version]: pass else: logger.info( f"Installing/updating addon: {addon_name} to version: {latest_version}...\n" ) try: zip_url = site.find_zip_url() addon_zip = self.get_addon_zip(site.session, zip_url) self.extract_to_addons(addon_zip, subfolder, site) except HTTPError: logger.exception(f"Failed to download zip for [{addon_name}]") latest_version = AddonManager._UNAVAILABLE except KeyError: logger.exception( f"Failed to extract subfolder [{subfolder}] in archive for [{addon_name}]" ) latest_version = AddonManager._UNAVAILABLE except SiteError as e: logger.exception(e) latest_version = AddonManager._UNAVAILABLE except Exception as e: logger.exception(f"Unexpected error unzipping [{addon_name}]") latest_version = AddonManager._UNAVAILABLE addon_entry = [ addon_name, addon_url, installed_version, latest_version ] self.manifest.append(addon_entry)
def update_addon(self, addon_entry): if not addon_entry or addon_entry.startswith('#'): return # Expected format: "mydomain.com/myzip.zip" or "mydomain.com/myzip.zip|subfolder" addon_url, *subfolder = addon_entry.split('|') site = site_handler.get_handler(addon_url) addon_name = site.get_addon_name() try: latest_version = site.get_latest_version() except Exception: print(f"Failed to retrieve latest version for {addon_name}.\n") latest_version = AddonManager._UNAVAILABLE installed_version = self.get_installed_version(addon_name) if latest_version == AddonManager._UNAVAILABLE: pass elif latest_version == installed_version: print(f"{addon_name} version {installed_version} is up to date.\n") else: print( f"Installing/updating addon: {addon_name} to version: {latest_version}...\n" ) try: zip_url = site.find_zip_url() addon_zip = self.get_addon_zip(zip_url) self.extract_to_addons(addon_zip, subfolder) except HTTPError: print(f"Failed to download zip for [{addon_name}]") latest_version = AddonManager._UNAVAILABLE except KeyError: print( f"Failed to find subfolder [{subfolder}] in archive for [{addon_name}]" ) latest_version = AddonManager._UNAVAILABLE except Exception: print(f"Unexpected error unzipping [{addon_name}]") latest_version = AddonManager._UNAVAILABLE addon_entry = [ addon_name, addon_url, installed_version, latest_version ] self.manifest.append(addon_entry)
def test_handles_wowinterface(self): for url in Tukui.get_supported_urls(): handler = site_handler.get_handler(url, GameVersion.retail) self.assertIsInstance(handler, Tukui)
def test_handles_tukui(self): for url in WoWInterface.get_supported_urls(): handler = site_handler.get_handler(url, GameVersion.retail) self.assertIsInstance(handler, WoWInterface)
def test_handles_curse_prerelease(self): addon_versions = AddonVersion.__members__.values() for url in Curse.get_supported_urls(): for version in addon_versions: handler = site_handler.get_handler(url, GameVersion.retail, version) self.assertEqual(handler.addon_version, version)
def test_handles_curse(self): for url in Curse.get_supported_urls(): handler = site_handler.get_handler(url, GameVersion.retail) self.assertIsInstance(handler, Curse)
def test_handles_wowace(self): for url in WoWAce.get_supported_urls(): handler = site_handler.get_handler(url) self.assertIsInstance(handler, WoWAce)
def test_handles_curse(self): for url in Curse.get_supported_urls(): Curse._convert_old_curse_urls = MagicMock(return_value=url) handler = site_handler.get_handler(url) self.assertIsInstance(handler, Curse)