mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Fix exceptions raising (args not kwargs)
This commit is contained in:
parent
76e46807a0
commit
6346d23010
@ -40,7 +40,7 @@ class SteamCMD:
|
|||||||
|
|
||||||
if not os.path.isdir(self._installation_path):
|
if not os.path.isdir(self._installation_path):
|
||||||
raise NotADirectoryError(
|
raise NotADirectoryError(
|
||||||
message=f"No valid directory found at {self._installation_path}"
|
f"No valid directory found at {self._installation_path}. "
|
||||||
"Please make sure that the directory is correct."
|
"Please make sure that the directory is correct."
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,11 +54,9 @@ class SteamCMD:
|
|||||||
self.platform = platform.system()
|
self.platform = platform.system()
|
||||||
if self.platform not in ["Windows", "Linux"]:
|
if self.platform not in ["Windows", "Linux"]:
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
message=(
|
|
||||||
f"Non supported operating system. "
|
f"Non supported operating system. "
|
||||||
f"Expected Windows, or Linux, got {self.platform}"
|
f"Expected Windows, or Linux, got {self.platform}"
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
self.steamcmd_url = package_links[self.platform]["url"]
|
self.steamcmd_url = package_links[self.platform]["url"]
|
||||||
self.zip = "steamcmd" + package_links[self.platform]["d_extension"]
|
self.zip = "steamcmd" + package_links[self.platform]["d_extension"]
|
||||||
@ -85,7 +83,7 @@ class SteamCMD:
|
|||||||
return data
|
return data
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise FileNotFoundError(
|
raise FileNotFoundError(
|
||||||
message=f"An unknown exception occurred during downloading. {e}"
|
f"An unknown exception occurred during downloading. {e}"
|
||||||
) from e
|
) from e
|
||||||
|
|
||||||
def _extract_steamcmd(self):
|
def _extract_steamcmd(self):
|
||||||
@ -104,7 +102,7 @@ class SteamCMD:
|
|||||||
else:
|
else:
|
||||||
# This should never happen, but let's just throw it just in case.
|
# This should never happen, but let's just throw it just in case.
|
||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
message="The operating system is not supported."
|
"The operating system is not supported."
|
||||||
f"Expected Linux or Windows, received: {self.platform}"
|
f"Expected Linux or Windows, received: {self.platform}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -138,7 +136,7 @@ class SteamCMD:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
raise FileExistsError(
|
raise FileExistsError(
|
||||||
message="Steamcmd is already installed. Reinstall is not necessary."
|
"Steamcmd is already installed. Reinstall is not necessary."
|
||||||
"Use force=True to override."
|
"Use force=True to override."
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
@ -148,7 +146,7 @@ class SteamCMD:
|
|||||||
logger.error("SteamCMD has returned error code 7 on fresh installation")
|
logger.error("SteamCMD has returned error code 7 on fresh installation")
|
||||||
return
|
return
|
||||||
raise SystemError(
|
raise SystemError(
|
||||||
message=f"Failed to install, check error code {e.returncode}"
|
f"Failed to install, check error code {e.returncode}"
|
||||||
) from e
|
) from e
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -229,7 +227,7 @@ class SteamCMD:
|
|||||||
"""
|
"""
|
||||||
if n_tries == 0:
|
if n_tries == 0:
|
||||||
raise TimeoutError(
|
raise TimeoutError(
|
||||||
message="""Error executing command, max number of retries exceeded!
|
"""Error executing command, max number of retries exceeded!
|
||||||
Consider increasing the n_tries parameter if the download is
|
Consider increasing the n_tries parameter if the download is
|
||||||
particularly large"""
|
particularly large"""
|
||||||
)
|
)
|
||||||
@ -262,4 +260,14 @@ class SteamCMD:
|
|||||||
)
|
)
|
||||||
return self.execute(cmd, n_tries - 1)
|
return self.execute(cmd, n_tries - 1)
|
||||||
|
|
||||||
raise SystemError(f"Steamcmd was unable to run. exit code was {e}") from e
|
# Specifically handle the case of exit code 8, insufficient disk space.
|
||||||
|
if e.returncode == 8:
|
||||||
|
raise SystemError(
|
||||||
|
"""SteamCMD was unable to run due to
|
||||||
|
insufficient disk space. Exit code was 8."""
|
||||||
|
) from e
|
||||||
|
|
||||||
|
# Handle other non-zero exit codes with a general error message.
|
||||||
|
raise SystemError(
|
||||||
|
f"SteamCMD was unable to run. Exit code was {e.returncode}."
|
||||||
|
) from e
|
||||||
|
Loading…
Reference in New Issue
Block a user