Compare commits
3 Commits
8ff2a388d7
...
4d8f4008f2
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d8f4008f2 | |||
| 208c6efd1e | |||
| 156c42c1f3 |
@ -148,7 +148,7 @@ class VoicepackUpdateAll(Command):
|
|||||||
game_info = State.game.get_remote_game(pre_download=pre_download)
|
game_info = State.game.get_remote_game(pre_download=pre_download)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
progress.finish(
|
progress.finish(
|
||||||
f"<error>Update checking failed with following error: {e} ({e.__context__})</error>"
|
f"<error>Update checking failed with following error: {e} \n({traceback.format_exc()})</error>"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
if update_diff is None:
|
if update_diff is None:
|
||||||
@ -192,7 +192,7 @@ class VoicepackUpdateAll(Command):
|
|||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
progress.finish(
|
progress.finish(
|
||||||
f"<error>Couldn't apply update: {e} ({e.__context__})</error>"
|
f"<error>Couldn't apply update: {e} \n({traceback.format_exc()})</error>"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
progress.finish(
|
progress.finish(
|
||||||
@ -228,7 +228,7 @@ class UpdatePatchCommand(Command):
|
|||||||
patcher.update_patch()
|
patcher.update_patch()
|
||||||
except PatchUpdateError as e:
|
except PatchUpdateError as e:
|
||||||
progress.finish(
|
progress.finish(
|
||||||
f"<error>Patch update failed with following error: {e} ({e.__context__})</error>"
|
f"<error>Patch update failed with following error: {e} \n({traceback.format_exc()})</error>"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
progress.finish("<comment>Patch updated!</comment>")
|
progress.finish("<comment>Patch updated!</comment>")
|
||||||
@ -246,7 +246,7 @@ class PatchInstallCommand(Command):
|
|||||||
jadeite_dir = patcher.patch_game(game=State.game)
|
jadeite_dir = patcher.patch_game(game=State.game)
|
||||||
except PatcherError as e:
|
except PatcherError as e:
|
||||||
progress.finish(
|
progress.finish(
|
||||||
f"<error>Patch installation failed with following error: {e} ({e.__context__})</error>"
|
f"<error>Patch installation failed with following error: {e} \n({traceback.format_exc()})</error>"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
progress.finish("<comment>Patch installed!</comment>")
|
progress.finish("<comment>Patch installed!</comment>")
|
||||||
@ -279,7 +279,7 @@ class PatchInstallCommand(Command):
|
|||||||
patcher.patch_game(game=State.game)
|
patcher.patch_game(game=State.game)
|
||||||
except PatcherError as e:
|
except PatcherError as e:
|
||||||
progress.finish(
|
progress.finish(
|
||||||
f"<error>Patch installation failed with following error: {e} ({e.__context__})</error>"
|
f"<error>Patch installation failed with following error: {e} \n({traceback.format_exc()})</error>"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
progress.finish("<comment>Patch installed!</comment>")
|
progress.finish("<comment>Patch installed!</comment>")
|
||||||
@ -327,7 +327,7 @@ class PatchInstallCommand(Command):
|
|||||||
patcher.block_telemetry(telemetry_list=telemetry_list)
|
patcher.block_telemetry(telemetry_list=telemetry_list)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.line_error(
|
self.line_error(
|
||||||
f"<error>Couldn't block telemetry hosts: {e.__context__}</error>"
|
f"<error>Couldn't block telemetry hosts: {traceback.format_exc()}</error>"
|
||||||
)
|
)
|
||||||
# There's a good reason for this.
|
# There's a good reason for this.
|
||||||
if system() != "Windows":
|
if system() != "Windows":
|
||||||
@ -344,7 +344,7 @@ class PatchInstallCommand(Command):
|
|||||||
patcher.update_patch()
|
patcher.update_patch()
|
||||||
except PatchUpdateError as e:
|
except PatchUpdateError as e:
|
||||||
progress.finish(
|
progress.finish(
|
||||||
f"<error>Patch update failed with following error: {e} ({e.__context__})</error>"
|
f"<error>Patch update failed with following error: {e} \n({traceback.format_exc()})</error>"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
progress.finish("<comment>Patch updated.</comment>")
|
progress.finish("<comment>Patch updated.</comment>")
|
||||||
@ -386,7 +386,7 @@ class PatchTelemetryCommand(Command):
|
|||||||
patcher.block_telemetry(telemetry_list=telemetry_list)
|
patcher.block_telemetry(telemetry_list=telemetry_list)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.line_error(
|
self.line_error(
|
||||||
f"<error>Couldn't block telemetry hosts: {e.__context__}</error>"
|
f"<error>Couldn't block telemetry hosts: {traceback.format_exc()}</error>"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
progress.finish("<comment>No telemetry hosts found.</comment>")
|
progress.finish("<comment>No telemetry hosts found.</comment>")
|
||||||
@ -436,9 +436,8 @@ class UpdateCommand(Command):
|
|||||||
update_diff = State.game.get_update(pre_download=pre_download)
|
update_diff = State.game.get_update(pre_download=pre_download)
|
||||||
game_info = State.game.get_remote_game(pre_download=pre_download)
|
game_info = State.game.get_remote_game(pre_download=pre_download)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(traceback.format_exc())
|
|
||||||
progress.finish(
|
progress.finish(
|
||||||
f"<error>Update checking failed with following error: {e} ({e.__context__})</error>"
|
f"<error>Update checking failed with following error: {e} \n({traceback.format_exc()})</error>"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
if update_diff is None or isinstance(game_info.major, str | None):
|
if update_diff is None or isinstance(game_info.major, str | None):
|
||||||
@ -475,7 +474,7 @@ class UpdateCommand(Command):
|
|||||||
State.game.apply_update_archive(out_path, auto_repair=auto_repair)
|
State.game.apply_update_archive(out_path, auto_repair=auto_repair)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
progress.finish(
|
progress.finish(
|
||||||
f"<error>Couldn't apply update: {e} ({e.__context__})</error>"
|
f"<error>Couldn't apply update: {e} \n({traceback.format_exc()})</error>"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
progress.finish("<comment>Update applied for base game.</comment>")
|
progress.finish("<comment>Update applied for base game.</comment>")
|
||||||
@ -506,7 +505,7 @@ class UpdateCommand(Command):
|
|||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
progress.finish(
|
progress.finish(
|
||||||
f"<error>Couldn't apply update: {e} ({e.__context__})</error>"
|
f"<error>Couldn't apply update: {e} \n({traceback.format_exc()})</error>"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
progress.finish(
|
progress.finish(
|
||||||
@ -543,7 +542,7 @@ class RepairCommand(Command):
|
|||||||
State.game.repair_game()
|
State.game.repair_game()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
progress.finish(
|
progress.finish(
|
||||||
f"<error>Repairation failed with following error: {e} ({e.__context__})</error>"
|
f"<error>Repairation failed with following error: {e} \n({traceback.format_exc()})</error>"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
progress.finish("<comment>Repairation completed.</comment>")
|
progress.finish("<comment>Repairation completed.</comment>")
|
||||||
@ -579,10 +578,10 @@ class UpdateDownloadCommand(Command):
|
|||||||
game_info = State.game.get_remote_game(pre_download=pre_download)
|
game_info = State.game.get_remote_game(pre_download=pre_download)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
progress.finish(
|
progress.finish(
|
||||||
f"<error>Update checking failed with following error: {e} ({e.__context__})</error>"
|
f"<error>Update checking failed with following error: {e} \n({traceback.format_exc()})</error>"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
if update_diff is None:
|
if update_diff is None or isinstance(game_info.major, str | None):
|
||||||
progress.finish("<comment>Game is already updated.</comment>")
|
progress.finish("<comment>Game is already updated.</comment>")
|
||||||
return
|
return
|
||||||
progress.finish("<comment>Update available.</comment>")
|
progress.finish("<comment>Update available.</comment>")
|
||||||
@ -590,16 +589,17 @@ class UpdateDownloadCommand(Command):
|
|||||||
f"The current version is: <comment>{State.game.get_version_str()}</comment>"
|
f"The current version is: <comment>{State.game.get_version_str()}</comment>"
|
||||||
)
|
)
|
||||||
self.line(
|
self.line(
|
||||||
f"The latest version is: <comment>{game_info.latest.version}</comment>"
|
f"The latest version is: <comment>{game_info.major.version}</comment>"
|
||||||
)
|
)
|
||||||
if not self.confirm("Do you want to download the update?"):
|
if not self.confirm("Do you want to download the update?"):
|
||||||
self.line("<error>Download aborted.</error>")
|
self.line("<error>Download aborted.</error>")
|
||||||
return
|
return
|
||||||
self.line("Downloading update package...")
|
self.line("Downloading update package...")
|
||||||
out_path = State.game.cache.joinpath(update_diff.name)
|
update_game_url = update_diff.game_pkgs[0].url
|
||||||
|
out_path = State.game.cache.joinpath(PurePath(update_game_url).name)
|
||||||
try:
|
try:
|
||||||
download_result = utils.download(
|
download_result = utils.download(
|
||||||
update_diff.path, out_path, file_len=update_diff.size
|
update_game_url, out_path, file_len=update_diff.game_pkgs[0].size
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.line_error(f"<error>Couldn't download update: {e}</error>")
|
self.line_error(f"<error>Couldn't download update: {e}</error>")
|
||||||
@ -612,14 +612,14 @@ class UpdateDownloadCommand(Command):
|
|||||||
# Get installed voicepacks
|
# Get installed voicepacks
|
||||||
installed_voicepacks = State.game.get_installed_voicepacks()
|
installed_voicepacks = State.game.get_installed_voicepacks()
|
||||||
# Voicepack update
|
# Voicepack update
|
||||||
for remote_voicepack in update_diff.voice_packs:
|
for remote_voicepack in update_diff.audio_pkgs:
|
||||||
if remote_voicepack.language not in installed_voicepacks:
|
if remote_voicepack.language not in installed_voicepacks:
|
||||||
continue
|
continue
|
||||||
# Voicepack is installed, update it
|
# Voicepack is installed, update it
|
||||||
archive_file = State.game.cache.joinpath(remote_voicepack.name)
|
archive_file = State.game.cache.joinpath(PurePath(remote_voicepack.url).name)
|
||||||
try:
|
try:
|
||||||
download_result = utils.download(
|
download_result = utils.download(
|
||||||
remote_voicepack.path, archive_file, file_len=update_diff.size
|
remote_voicepack.url, archive_file, file_len=remote_voicepack.size
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.line_error(f"<error>Couldn't download update: {e}</error>")
|
self.line_error(f"<error>Couldn't download update: {e}</error>")
|
||||||
@ -652,7 +652,7 @@ class ApplyUpdateArchive(Command):
|
|||||||
State.game.apply_update_archive(update_archive, auto_repair=auto_repair)
|
State.game.apply_update_archive(update_archive, auto_repair=auto_repair)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
progress.finish(
|
progress.finish(
|
||||||
f"<error>Couldn't apply update: {e} ({e.__context__})</error>"
|
f"<error>Couldn't apply update: {e} \n({traceback.format_exc()})</error>"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
progress.finish("<comment>Update applied.</comment>")
|
progress.finish("<comment>Update applied.</comment>")
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
from vollerei.common.enums import VoicePackLanguage
|
from vollerei.common.enums import VoicePackLanguage
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
|
||||||
class Game:
|
class Game:
|
||||||
@ -99,8 +100,19 @@ class PreDownload:
|
|||||||
self.major = major
|
self.major = major
|
||||||
self.patches = patches
|
self.patches = patches
|
||||||
|
|
||||||
|
# Union to fix the typing issue.
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_dict(data: dict) -> "PreDownload":
|
def from_dict(data: dict | None) -> Union["PreDownload", None]:
|
||||||
|
# pre_download can be null in the server for certain games
|
||||||
|
# e.g. HI3:
|
||||||
|
# "pre_download": null
|
||||||
|
# while in GI it is the following:
|
||||||
|
# "pre_download": {
|
||||||
|
# "major": null,
|
||||||
|
# "patches": []
|
||||||
|
# }
|
||||||
|
if data is None:
|
||||||
|
return None
|
||||||
return PreDownload(
|
return PreDownload(
|
||||||
major=(
|
major=(
|
||||||
data["major"]
|
data["major"]
|
||||||
|
|||||||
@ -349,11 +349,11 @@ class Game(GameABC):
|
|||||||
return patch
|
return patch
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _repair_file(self, file: PathLike, game: resource.Game) -> None:
|
def _repair_file(self, file: PathLike, game: resource.Main) -> None:
|
||||||
# .replace("\\", "/") is needed because Windows uses backslashes :)
|
# .replace("\\", "/") is needed because Windows uses backslashes :)
|
||||||
relative_file = file.relative_to(self._path)
|
relative_file = file.relative_to(self._path)
|
||||||
url = (
|
url = (
|
||||||
game.latest.decompressed_path + "/" + str(relative_file).replace("\\", "/")
|
game.major.res_list_url + "/" + str(relative_file).replace("\\", "/")
|
||||||
)
|
)
|
||||||
# Backup the file
|
# Backup the file
|
||||||
if file.exists():
|
if file.exists():
|
||||||
@ -409,7 +409,7 @@ class Game(GameABC):
|
|||||||
game = self.get_remote_game(pre_download=pre_download)
|
game = self.get_remote_game(pre_download=pre_download)
|
||||||
else:
|
else:
|
||||||
game = game_info
|
game = game_info
|
||||||
if game.latest.decompressed_path is None:
|
if isinstance(game.major, str | None) or game.major.res_list_url in [None, ""]:
|
||||||
raise ScatteredFilesNotAvailableError("Scattered files are not available.")
|
raise ScatteredFilesNotAvailableError("Scattered files are not available.")
|
||||||
self._repair_file(file, game=game)
|
self._repair_file(file, game=game)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user