mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Add try/except around download
This commit is contained in:
parent
b274f0d3b0
commit
bd38fcd6e4
@ -1115,24 +1115,33 @@ class ServerInstance:
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# downloads zip from remote url
|
# downloads zip from remote url
|
||||||
bedrock_url = Helpers.get_latest_bedrock_url()
|
try:
|
||||||
if bedrock_url.lower().startswith("https"):
|
bedrock_url = Helpers.get_latest_bedrock_url()
|
||||||
urllib.request.urlretrieve(
|
if bedrock_url.lower().startswith("https"):
|
||||||
bedrock_url,
|
urllib.request.urlretrieve(
|
||||||
os.path.join(self.settings["path"], "bedrock_server.zip"),
|
bedrock_url,
|
||||||
|
os.path.join(self.settings["path"], "bedrock_server.zip"),
|
||||||
|
)
|
||||||
|
|
||||||
|
unzip_path = os.path.join(self.settings["path"], "bedrock_server.zip")
|
||||||
|
unzip_path = self.helper.wtol_path(unzip_path)
|
||||||
|
# unzips archive that was downloaded.
|
||||||
|
FileHelpers.unzip_file(unzip_path)
|
||||||
|
# adjusts permissions for execution if os is not windows
|
||||||
|
if not self.helper.is_os_windows():
|
||||||
|
os.chmod(
|
||||||
|
os.path.join(self.settings["path"], "bedrock_server"), 0o0744
|
||||||
|
)
|
||||||
|
|
||||||
|
# we'll delete the zip we downloaded now
|
||||||
|
os.remove(os.path.join(self.settings["path"], "bedrock_server.zip"))
|
||||||
|
downloaded = True
|
||||||
|
except Exception as e:
|
||||||
|
logger.critical(
|
||||||
|
f"Failed to download bedrock executable for update \n{e}"
|
||||||
)
|
)
|
||||||
|
downloaded = True
|
||||||
unzip_path = os.path.join(self.settings["path"], "bedrock_server.zip")
|
return
|
||||||
unzip_path = self.helper.wtol_path(unzip_path)
|
|
||||||
# unzips archive that was downloaded.
|
|
||||||
FileHelpers.unzip_file(unzip_path)
|
|
||||||
# adjusts permissions for execution if os is not windows
|
|
||||||
if not self.helper.is_os_windows():
|
|
||||||
os.chmod(os.path.join(self.settings["path"], "bedrock_server"), 0o0744)
|
|
||||||
|
|
||||||
# we'll delete the zip we downloaded now
|
|
||||||
os.remove(os.path.join(self.settings["path"], "bedrock_server.zip"))
|
|
||||||
downloaded = True
|
|
||||||
|
|
||||||
while self.stats_helper.get_server_stats()["updating"]:
|
while self.stats_helper.get_server_stats()["updating"]:
|
||||||
if downloaded and not self.is_backingup:
|
if downloaded and not self.is_backingup:
|
||||||
|
Loading…
Reference in New Issue
Block a user