Skip to content

Commit 2838b67

Browse files
authored
Merge pull request #2699 from 2dos/update_messages
Add messages
2 parents a858c27 + 5f803ed commit 2838b67

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed

ap_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Holds the version for Archipelago."""
22

3-
version = "1.0.50"
3+
version = "1.0.51"

archipelago/client/common.py

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -161,48 +161,50 @@ def check_version():
161161
# Check if we're installed in an apworld in custom_worlds/dk64.apworld
162162
# Check if the file exists
163163
apworld_output = "./custom_worlds/dk64.apworld"
164-
if os.path.exists(apworld_output):
165-
should_install = ask_yes_no_cancel("Update Available", "A new version of DK64 Rando is available. Would you like to install it?")
166-
if not should_install:
167-
return
168-
169-
# Find the dk64.apworld asset in the release
170-
assets = data.get("assets", [])
171-
apworld_asset = None
172-
for asset in assets:
173-
if asset.get("name") == "dk64.apworld":
174-
apworld_asset = asset
175-
break
176-
177-
if not apworld_asset:
178-
logger.warning("No dk64.apworld asset found in the latest release")
179-
return
180-
181-
download_url = apworld_asset.get("browser_download_url")
182-
if not download_url:
183-
logger.warning("No download URL found for dk64.apworld asset")
184-
return
185-
186-
try:
187-
with urllib.request.urlopen(download_url) as response:
188-
data = response.read()
189-
# Delete the original AP World in the folder
190-
os.remove(apworld_output)
191-
# Save as .apworld
192-
with open(apworld_output, "wb") as f:
193-
f.write(data)
194-
print(f"APWorld file saved as {apworld_output}")
195-
root = Tk()
196-
root.withdraw()
197-
messagebox.showinfo("Update Complete", f"New version of DK64 Rando installed as {apworld_output}")
198-
root.update()
199-
sys.exit(1)
200-
except Exception as e:
201-
logger.warning(f"Failed to download or save the new APWorld file: {e}")
164+
if os.path.exists(apworld_output):
165+
should_install = ask_yes_no_cancel("Update Available", "A new version of DK64 Rando is available. Would you like to install it?")
166+
if not should_install:
167+
return
168+
169+
# Find the dk64.apworld asset in the release
170+
assets = data.get("assets", [])
171+
apworld_asset = None
172+
for asset in assets:
173+
if asset.get("name") == "dk64.apworld":
174+
apworld_asset = asset
175+
break
176+
177+
if not apworld_asset:
178+
logger.warning("No dk64.apworld asset found in the latest release")
179+
return
180+
181+
download_url = apworld_asset.get("browser_download_url")
182+
if not download_url:
183+
logger.warning("No download URL found for dk64.apworld asset")
184+
return
185+
186+
try:
187+
with urllib.request.urlopen(download_url) as response:
188+
data = response.read()
189+
# Delete the original AP World in the folder
190+
os.remove(apworld_output)
191+
# Save as .apworld
192+
with open(apworld_output, "wb") as f:
193+
f.write(data)
194+
print(f"APWorld file saved as {apworld_output}")
195+
root = Tk()
196+
root.withdraw()
197+
messagebox.showinfo("Update Complete", f"New version of DK64 Rando installed as {apworld_output}")
198+
root.update()
199+
sys.exit(1)
200+
except Exception as e:
201+
logger.warning(f"Failed to download or save the new APWorld file: {e}")
202+
else:
203+
logger.warning("-" * 50)
204+
logger.warning("New version of DK64 Rando available, but no APWorld file found. Please update manually.")
205+
logger.warning("-" * 50)
202206
else:
203-
logger.warning("-" * 50)
204-
logger.warning("New version of DK64 Rando available, but no APWorld file found. Please update manually.")
205-
logger.warning("-" * 50)
207+
logger.info("You are running the latest version of DK64 Rando.")
206208
except Exception as e:
207209
print(e)
208210
print("Failed to check for new version of DK64")

0 commit comments

Comments
 (0)