Put try/except around creation

This commit is contained in:
amcmanu3 2022-08-31 20:01:38 -04:00
parent a07eb58db7
commit 2becb657ca

View File

@ -226,24 +226,29 @@ class ImportHelpers:
download_thread.start()
def download_threaded_bedrock_server(self, path, new_id):
# downloads zip from remote url
bedrock_url = Helpers.get_latest_bedrock_url()
if bedrock_url.lower().startswith("https"):
urllib.request.urlretrieve(
bedrock_url,
os.path.join(path, "bedrock_server.zip"),
)
try:
bedrock_url = Helpers.get_latest_bedrock_url()
if bedrock_url.lower().startswith("https"):
urllib.request.urlretrieve(
bedrock_url,
os.path.join(path, "bedrock_server.zip"),
)
unzip_path = os.path.join(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(path, "bedrock_server"), 0o0744)
unzip_path = os.path.join(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(path, "bedrock_server"), 0o0744)
# we'll delete the zip we downloaded now
os.remove(os.path.join(path, "bedrock_server.zip"))
except Exception as e:
logger.critical(f"Failed to download bedrock executable for update \n{e}")
# we'll delete the zip we downloaded now
os.remove(os.path.join(path, "bedrock_server.zip"))
ServersController.finish_import(new_id)
server_users = PermissionsServers.get_server_user_list(new_id)
for user in server_users: