Improve resource pack downloading (#1042)
* Improve resource pack downloading Fixed trackback in GUI. Added message dialog to allow the user to retry downloading. * Reformatted
This commit is contained in:
parent
9a3d9c5a3a
commit
1e22d83a4b
@ -143,6 +143,7 @@ program_3d_edit.canvas.java_rp_failed=Failed to download the latest Java resourc
|
|||||||
program_3d_edit.canvas.java_rp_failed_default=Check your internet connection and restart Amulet.
|
program_3d_edit.canvas.java_rp_failed_default=Check your internet connection and restart Amulet.
|
||||||
program_3d_edit.canvas.java_rp_failed_mac_certificates=The certificates to access the internet were not installed.\nRun the "Install Certificates.command" program that can be found in "Applications/Python 3.x".
|
program_3d_edit.canvas.java_rp_failed_mac_certificates=The certificates to access the internet were not installed.\nRun the "Install Certificates.command" program that can be found in "Applications/Python 3.x".
|
||||||
program_3d_edit.canvas.loading_resource_packs=Loading resource packs
|
program_3d_edit.canvas.loading_resource_packs=Loading resource packs
|
||||||
|
program_3d_edit.canvas.retry_download=Failed to download the resource pack. Do you want to retry?
|
||||||
program_3d_edit.canvas.creating_texture_atlas=Creating texture atlas
|
program_3d_edit.canvas.creating_texture_atlas=Creating texture atlas
|
||||||
program_3d_edit.canvas.setting_up_renderer=Setting up renderer
|
program_3d_edit.canvas.setting_up_renderer=Setting up renderer
|
||||||
|
|
||||||
|
@ -145,42 +145,55 @@ class BaseEditCanvas(EventCanvas):
|
|||||||
yield 0.1, lang.get(
|
yield 0.1, lang.get(
|
||||||
"program_3d_edit.canvas.downloading_java_vanilla_resource_pack"
|
"program_3d_edit.canvas.downloading_java_vanilla_resource_pack"
|
||||||
)
|
)
|
||||||
gen = get_java_vanilla_latest_iter()
|
while True:
|
||||||
try:
|
gen = get_java_vanilla_latest_iter()
|
||||||
while True:
|
try:
|
||||||
yield next(gen) * 0.4 + 0.1
|
while True:
|
||||||
except StopIteration as e:
|
yield next(gen) * 0.4 + 0.1
|
||||||
packs.append(e.value)
|
except StopIteration as e:
|
||||||
except Exception as e:
|
packs.append(e.value)
|
||||||
if sys.platform == "darwin" and "CERTIFICATE_VERIFY_FAILED" in str(e):
|
break
|
||||||
msg = lang.get(
|
except Exception as e:
|
||||||
"program_3d_edit.canvas.java_rp_failed_mac_certificates"
|
if sys.platform == "darwin" and "CERTIFICATE_VERIFY_FAILED" in str(
|
||||||
)
|
e
|
||||||
else:
|
):
|
||||||
msg = lang.get("program_3d_edit.canvas.java_rp_failed_default")
|
msg = lang.get(
|
||||||
log.error(
|
"program_3d_edit.canvas.java_rp_failed_mac_certificates"
|
||||||
msg,
|
|
||||||
exc_info=True,
|
|
||||||
)
|
|
||||||
wait = True
|
|
||||||
|
|
||||||
def show_error():
|
|
||||||
nonlocal wait
|
|
||||||
try:
|
|
||||||
dialog = TracebackDialog(
|
|
||||||
self,
|
|
||||||
lang.get("program_3d_edit.canvas.java_rp_failed"),
|
|
||||||
f"{msg}\n{e}",
|
|
||||||
traceback.format_exc(),
|
|
||||||
)
|
)
|
||||||
dialog.ShowModal()
|
else:
|
||||||
dialog.Destroy()
|
msg = lang.get("program_3d_edit.canvas.java_rp_failed_default")
|
||||||
finally:
|
log.error(
|
||||||
wait = False
|
msg,
|
||||||
|
exc_info=True,
|
||||||
|
)
|
||||||
|
wait = True
|
||||||
|
tb = traceback.format_exc()
|
||||||
|
|
||||||
wx.CallAfter(show_error)
|
def show_error():
|
||||||
while wait:
|
nonlocal wait
|
||||||
time.sleep(0.1)
|
try:
|
||||||
|
dialog = TracebackDialog(
|
||||||
|
self,
|
||||||
|
lang.get("program_3d_edit.canvas.java_rp_failed"),
|
||||||
|
f"{msg}\n{e}",
|
||||||
|
tb,
|
||||||
|
)
|
||||||
|
dialog.ShowModal()
|
||||||
|
dialog.Destroy()
|
||||||
|
finally:
|
||||||
|
wait = False
|
||||||
|
|
||||||
|
wx.CallAfter(show_error)
|
||||||
|
while wait:
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
msg = wx.MessageDialog(
|
||||||
|
self,
|
||||||
|
lang.get("program_3d_edit.canvas.retry_download"),
|
||||||
|
style=wx.YES_NO,
|
||||||
|
)
|
||||||
|
if msg.ShowModal() == wx.ID_NO:
|
||||||
|
break
|
||||||
|
|
||||||
yield 0.5, lang.get("program_3d_edit.canvas.loading_resource_packs")
|
yield 0.5, lang.get("program_3d_edit.canvas.loading_resource_packs")
|
||||||
packs += [pack for pack in user_packs if isinstance(pack, JavaResourcePack)]
|
packs += [pack for pack in user_packs if isinstance(pack, JavaResourcePack)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user